public void WhenCreatedThenCreatedEventIsStored() { _auction.CommitAsync(_eventStore); var domainEvent = (AuctionCreatedEvent)_eventStore.GetLastEvent(_auction.Id); Assert.Equal("one", domainEvent.Name); Assert.Equal(_auction.AuctionDate, domainEvent.AuctionDate); }
public async Task InitializeAsync() { _auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); _eventStore = new InMemoryEventStore(); await _auction.CommitAsync(_eventStore); _handler = new AddAuctionItemCommandHandler(_eventStore); }
public async Task WhenGettingAllEventsForIdThenPopulatesDomainEventFromPersistedEvent() { var auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); await auction.CommitAsync(_eventStore); var events = await _eventStore.GetEventsByIdAsync(auction.Id); Assert.Single(events.OfType <AuctionCreatedEvent>()); }
public async Task WhenCommittingEventsThenPersistenceEventsArePersisted() { var auction = new Core.Auctions.Auction("three", DateTimeOffset.UtcNow); await auction.CommitAsync(_eventStore); var persistedEvents = await _eventPersistence.LoadEventsAsync(auction.Id); Assert.Single(persistedEvents); }
public async Task WhenGettingAllEventsForIdThenReturnsAllDomainEventsWithId() { var auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); auction.AddAuctionItem(new AuctionItem("shoes", "joel")); await auction.CommitAsync(_eventStore); var events = await _eventStore.GetEventsByIdAsync(auction.Id); Assert.Equal(2, events.Length); }
public async Task WhenCommittingEventsThenEachEventIsPublished() { var auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); auction.AddAuctionItem(new AuctionItem("computer", "jack")); auction.AddAuctionItem(new AuctionItem("bob", "jack")); await auction.CommitAsync(_eventStore); Assert.Single(_eventBus.GetPublishedEvent <AuctionCreatedEvent, AuctionId>()); Assert.Equal(2, _eventBus.GetPublishedEvent <AuctionItemAddedEvent, AuctionId>().Length); }
public async Task InitializeAsync() { var auction = new Core.Auctions.Auction("some", DateTimeOffset.UtcNow); var eventStore = new InMemoryEventStore(); await auction.CommitAsync(eventStore); _existingAuctionId = auction.Id; _validator = new AddAuctionItemCommandValidator(eventStore); }
public async Task InitializeAsync() { var auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); auction.AddAuctionItem(new AuctionItem(AuctionItemName, "bill")); _eventStore = new InMemoryEventStore(); await auction.CommitAsync(_eventStore); _auctionId = auction.Id; _handler = new UpdateAuctionItemCommandHandler(_eventStore); }
public async Task InitializeAsync() { var auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); auction.AddAuctionItem(new AuctionItem(ItemName, "donor")); _existingAuctionId = auction.Id; var eventStore = new InMemoryEventStore(); await auction.CommitAsync(eventStore); _validator = new RemoveAuctionItemCommandValidator(eventStore); }
public async Task WhenLoadingAggregateThenAggregateIsPopulatedFromEvents() { var auction = new Core.Auctions.Auction("three", DateTimeOffset.UtcNow); auction.AddAuctionItem(new AuctionItem("hat", "joel")); await auction.CommitAsync(_eventStore); var aggregate = await _eventStore.LoadAggregateAsync <Core.Auctions.Auction, AuctionId>(auction.Id); Assert.Equal(auction.Id, aggregate.Id); Assert.Equal("three", aggregate.Name); Assert.Equal(auction.AuctionDate, aggregate.AuctionDate); Assert.Equal(auction.Items.First(), aggregate.Items.First()); }