Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created May 20, 2021 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/7a5f887e1f2bdf57236bdfd61b4fbd9e to your computer and use it in GitHub Desktop.
Save dcomartin/7a5f887e1f2bdf57236bdfd61b4fbd9e to your computer and use it in GitHub Desktop.
public class WarehouseProductTests
{
private readonly string _sku;
private readonly int _initialQuantity;
private readonly WarehouseProduct _sut;
private readonly Fixture _fixture;
public WarehouseProductTests()
{
_fixture = new Fixture();
_fixture.Customizations.Add(new Int32SequenceGenerator());
_sku = _fixture.Create<string>();
_initialQuantity = (int)_fixture.Create<uint>();
_sut = WarehouseProduct.Load(_sku, new [] {
new ProductReceived(_sku, _initialQuantity, DateTime.UtcNow)
});
}
[Fact]
public void ShipProductShouldRaiseProductShipped()
{
var quantityToShip = _fixture.Create<int>();
_sut.ShipProduct(quantityToShip);
var outEvents = _sut.GetUncommittedEvents();
outEvents.Count.ShouldBe(1);
var outEvent = outEvents.Single();
outEvent.ShouldBeOfType<ProductShipped>();
var productShipped = (ProductShipped)outEvent;
productShipped.ShouldSatisfyAllConditions(
x => x.Quantity.ShouldBe(quantityToShip),
x => x.Sku.ShouldBe(_sku),
x => x.EventType.ShouldBe("ProductShipped")
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment