Skip to content

Commit

Permalink
Added example NuGet Package public API snapshot testing with PublicAp…
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed May 17, 2024
1 parent 2ad2039 commit c9f7f45
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
<PackageReference Include="Verify.Xunit" Version="24.2.0" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using ECommerce.V1;
using PublicApiGenerator;

namespace EventsVersioning.Tests.SnapshotTesting;

public class PackageSnapshotTests
{
[Fact]
public Task my_assembly_has_no_public_api_changes()
{
var publicApi = typeof(ShoppingCartOpened).Assembly.GeneratePublicApi();

return Verify(publicApi);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")]
namespace ECommerce.V1
{
public class PricedProductItem : System.IEquatable<ECommerce.V1.PricedProductItem>
{
public PricedProductItem(ECommerce.V1.ProductItem ProductItem, decimal UnitPrice) { }
public ECommerce.V1.ProductItem ProductItem { get; init; }
public decimal UnitPrice { get; init; }
}
public class ProductItem : System.IEquatable<ECommerce.V1.ProductItem>
{
public ProductItem(System.Guid ProductId, int Quantity) { }
public System.Guid ProductId { get; init; }
public int Quantity { get; init; }
}
public class ProductItemAddedToShoppingCart : System.IEquatable<ECommerce.V1.ProductItemAddedToShoppingCart>
{
public ProductItemAddedToShoppingCart(System.Guid ShoppingCartId, ECommerce.V1.PricedProductItem ProductItem) { }
public ECommerce.V1.PricedProductItem ProductItem { get; init; }
public System.Guid ShoppingCartId { get; init; }
}
public class ProductItemRemovedFromShoppingCart : System.IEquatable<ECommerce.V1.ProductItemRemovedFromShoppingCart>
{
public ProductItemRemovedFromShoppingCart(System.Guid ShoppingCartId, ECommerce.V1.PricedProductItem ProductItem) { }
public ECommerce.V1.PricedProductItem ProductItem { get; init; }
public System.Guid ShoppingCartId { get; init; }
}
public class ShoppingCartConfirmed : System.IEquatable<ECommerce.V1.ShoppingCartConfirmed>
{
public ShoppingCartConfirmed(System.Guid ShoppingCartId, System.DateTime ConfirmedAt) { }
public System.DateTime ConfirmedAt { get; init; }
public System.Guid ShoppingCartId { get; init; }
}
public class ShoppingCartOpened : System.IEquatable<ECommerce.V1.ShoppingCartOpened>
{
public ShoppingCartOpened(System.Guid ShoppingCartId, System.Guid ClientId) { }
public System.Guid ClientId { get; init; }
public System.Guid ShoppingCartId { get; init; }
}
public enum ShoppingCartStatus
{
Pending = 1,
Confirmed = 2,
Cancelled = 3,
}
}

0 comments on commit c9f7f45

Please sign in to comment.