コード例 #1
0
        public async Task InitializeAsync()
        {
            _auction    = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow);
            _eventStore = new InMemoryEventStore();
            await _auction.CommitAsync(_eventStore);

            _handler = new AddAuctionItemCommandHandler(_eventStore);
        }
コード例 #2
0
        public void WhenCreatedThenAuctionIsPopulated()
        {
            var auctionDate = DateTimeOffset.UtcNow;
            var auction     = new Core.Auctions.Auction("one", auctionDate);

            Assert.Equal("one", auction.Name);
            Assert.Equal(auctionDate, auction.AuctionDate);
        }
コード例 #3
0
        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>());
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #10
0
        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());
        }
コード例 #11
0
 public AuctionTest()
 {
     _auction    = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow);
     _eventStore = new InMemoryEventStore();
 }