public async Task Given_no_stock_When_reserve_cancel_projected_Then_error_occurs() { var stockId = Guid.NewGuid(); var reserveExpired = new ReserveExpired(stockId, Guid.NewGuid()); await Assert.ThrowsAsync <SkuStockEntryNotFoundException>(() => ProjectionBuilder.Handle(reserveExpired)); }
public SkuStock_added_tests()// Given_sku_created_and_stock_added_messages_When_projected() { _stockCreatedEvent = new SkuStockCreated(Guid.NewGuid(), Guid.NewGuid(), 100, TimeSpan.FromDays(2)); _stockAddedEvent = new StockAdded(_stockCreatedEvent.SourceId, 15, "test pack"); ProjectionBuilder.Handle(_stockCreatedEvent).Wait(); ProjectionBuilder.Handle(_stockAddedEvent).Wait(); }
public async Task Given_no_reserve_When_reserve_taken_projected_Then_error_occurs() { var stockId = Guid.NewGuid(); var stockCreatedEvent = new SkuStockCreated(stockId, Guid.NewGuid(), 1, TimeSpan.FromDays(2)); var reserveTaken = new StockReserveTaken(stockId, Guid.NewGuid()); await ProjectionBuilder.Handle(stockCreatedEvent); await Assert.ThrowsAsync <ReserveEntryNotFoundException>(() => ProjectionBuilder.Handle(reserveTaken)); }
public SkuStock_taken_tests()// Given_sku_created_and_taken_messages_When_projected() { var stockId = Guid.NewGuid(); _stockCreatedEvent = new SkuStockCreated(stockId, Guid.NewGuid(), 5, TimeSpan.FromDays(2)); _stockTakenEvent = new StockTaken(stockId, 3); ProjectionBuilder.Handle(_stockCreatedEvent).Wait(); ProjectionBuilder.Handle(_stockTakenEvent).Wait(); }
public SkuStock_reserve_taken_tests()// Given_sku_created_and_stock_added_and_stock_reserved_messages_When_projected() { var stockId = Guid.NewGuid(); _stockCreatedEvent = new SkuStockCreated(stockId, Guid.NewGuid(), 1, TimeSpan.FromDays(2)); _stockReservedEvent = new StockReserved(stockId, Guid.NewGuid(), DateTime.Now.AddDays(1), 7); _stockReserveTakenEvent = new StockReserveTaken(stockId, _stockReservedEvent.ReserveId); ProjectionBuilder.Handle(_stockCreatedEvent).Wait(); ProjectionBuilder.Handle(_stockReservedEvent).Wait(); ProjectionBuilder.Handle(_stockReserveTakenEvent).Wait(); }
public async Task Given_sku_created_and_stock_added_and_stock_reserved_messages_When_projected() { var sourceId = Guid.NewGuid(); await ProjectionBuilder.Handle(new SkuStockCreated(sourceId, Guid.NewGuid(), 1, TimeSpan.FromDays(2))); await ProjectionBuilder.Handle(new StockAdded(sourceId, 15, "test pack")); var stockReserved = new StockReserved(sourceId, Guid.NewGuid(), DateTime.Now.AddDays(1), 7); await ProjectionBuilder.Handle(stockReserved); //When_project_reserve_again_error_is_occured() await ProjectionBuilder.Handle(stockReserved) .ShouldThrow <ArgumentException>(); }
public Account_projection_tests() { _msg = new AccountCreated(Guid.NewGuid(), Guid.NewGuid(), 42); var user = new User { Id = _msg.UserId, Login = "******" }; using (var context = CreateContext()) { context.Users.Add(user); context.SaveChanges(); } ProjectionBuilder.Handle(_msg).Wait(); }
public Order_created_projection_test()// Given_order_created_message() { _msg = new OrderCreated(Guid.NewGuid(), 123, Guid.NewGuid()); var user = new User { Id = _msg.User, Login = "******" }; using (var context = CreateContext()) { context.Users.Add(user); context.SaveChanges(); } ProjectionBuilder.Handle(_msg).Wait(); }
public async Task Given_sku_created_message_double_projected_When_project_again_additioanal_transaction_occures() { var stockCreatedEvent = new Fixture().Create <SkuStockCreated>(); var stockAddedEvent = new StockAdded(stockCreatedEvent.SourceId, 15, "test pack"); await ProjectionBuilder.Handle(stockCreatedEvent); await ProjectionBuilder.Handle(stockAddedEvent); await ProjectionBuilder.Handle(stockAddedEvent); using (var context = CreateContext()) { Assert.Equal(3, context.StockHistory.Count()); } }
public async Task Given_sku_created_and_stock_added_and_stock_reserved_messages_When_projected() { var stockId = Guid.NewGuid(); var stockCreatedEvent = new SkuStockCreated(stockId, Guid.NewGuid(), 1, TimeSpan.FromDays(2)); var stockReservedEvent = new StockReserved(stockId, Guid.NewGuid(), DateTime.Now.AddDays(1), 7); var stockReserveTakenEvent = new StockReserveTaken(stockId, stockReservedEvent.ReserveId); await ProjectionBuilder.Handle(stockCreatedEvent); await ProjectionBuilder.Handle(stockReservedEvent); await ProjectionBuilder.Handle(stockReserveTakenEvent); await Assert.ThrowsAsync <ReserveEntryNotFoundException>(() => ProjectionBuilder.Handle(stockReserveTakenEvent)); }
public async Task Given_sku_created_and_taken_messages_When_projected_Then_another_history_is_added() { var stockId = Guid.NewGuid(); var stockCreatedEvent = new SkuStockCreated(stockId, Guid.NewGuid(), 7, TimeSpan.FromDays(2)); var stockTaken = new StockTaken(stockId, 3); await ProjectionBuilder.Handle(stockCreatedEvent); await ProjectionBuilder.Handle(stockTaken); await ProjectionBuilder.Handle(stockTaken); using (var context = CreateContext()) { Assert.Equal(3, context.StockHistory.Count()); Assert.Equal(1, context.SkuStocks.Find(stockId).AvailableQuantity); } }
public async Task Given_sku_created_and_stock_added_and_stock_reserved_messages_When_projected_twice() { var stockId = Guid.NewGuid(); var stockCreatedEvent = new SkuStockCreated(stockId, Guid.NewGuid(), 1, TimeSpan.FromDays(2)); var stockAddedEvent = new StockAdded(stockId, 15, "test pack"); var stockReservedEvent = new StockReserved(stockId, Guid.NewGuid(), DateTime.Now.AddDays(1), 7); var reserveCanceledEvent = new ReserveCanceled(stockId, stockReservedEvent.ReserveId); await ProjectionBuilder.Handle(stockCreatedEvent); await ProjectionBuilder.Handle(stockAddedEvent); await ProjectionBuilder.Handle(stockReservedEvent); await ProjectionBuilder.Handle(reserveCanceledEvent); await ProjectionBuilder.Handle(reserveCanceledEvent) .ShouldThrow <ReserveEntryNotFoundException>(); }
public Account_transactions_projection_tests() { // Given_account_created_and_projecting() var msgCreated = new AccountCreated(Guid.NewGuid(), Guid.NewGuid(), 42); var user = new User { Id = msgCreated.UserId, Login = "******" }; _msgReplenish = new AccountReplenish(msgCreated.SourceId, Guid.NewGuid(), new Money(100)); _msgWithdrawal = new AccountWithdrawal(msgCreated.SourceId, Guid.NewGuid(), new Money(30)); using (var context = CreateContext()) { context.Users.Add(user); context.SaveChanges(); } ProjectionBuilder.Handle(msgCreated).Wait(); ProjectionBuilder.Handle(_msgReplenish).Wait(); ProjectionBuilder.Handle(_msgWithdrawal).Wait(); }
public async Task Given_no_stock_When_reserve_taken_projected_Then_error_occurs() { var reserveTaken = new StockReserveTaken(Guid.NewGuid(), Guid.NewGuid()); await Assert.ThrowsAsync <SkuStockEntryNotFoundException>(() => ProjectionBuilder.Handle(reserveTaken)); }
public async Task Should_fail_on_additional_project_attempt() { await Assert.ThrowsAsync <ArgumentException>(() => ProjectionBuilder.Handle(_msg)); }
public async Task Should_throw_exceptions_on_double_event() { await Assert.ThrowsAsync <ArgumentException>(() => ProjectionBuilder.Handle(_msg)); }
public async Task Given_stock_reserved_message_without_stock_created_When_projected_When_projected_then_error_occures() { await ProjectionBuilder.Handle(new StockReserved(Guid.NewGuid(), Guid.NewGuid(), DateTime.Now.AddDays(1), 7)) .ShouldThrow <SkuStockEntryNotFoundException>(); }
public async Task When_project_again_error_occures() { await ProjectionBuilder.Handle(_message) .ShouldThrow <ArgumentException>(); }
public async Task Given_sku_created_message_double_projected_When_project_Then_error_occures() { await ProjectionBuilder.Handle(new StockAdded(Guid.NewGuid(), 15, "test pack")) .ShouldThrow <SkuStockEntryNotFoundException>(); }
public Sku_created_projection_tests() //Given_sku_created_message_projected() { _message = new Fixture().Create <SkuCreated>(); ProjectionBuilder.Handle(_message).Wait(); }
public async Task When_project_again_error_occures() { await Assert.ThrowsAsync <ArgumentException>(() => ProjectionBuilder.Handle(_message)); }
protected override async Task HandleEventImplementation() { await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); }
public async Task Given_no_stock_When_stock_taken_projected_Then_error_occurs() { await ProjectionBuilder.Handle(new StockReserveTaken(Guid.NewGuid(), Guid.NewGuid())) .ShouldThrow <SkuStockEntryNotFoundException>(); }