Esempio n. 1
0
        public async Task WhenGettingAuctionItemsThenReturnsItemsMatchingAuctionId()
        {
            var auctionId = new AuctionId();

            _readStore.AddAuction(auctionId);
            _readStore.AddAuctionItem(auctionId, "shirts", "donor");
            _readStore.AddAuctionItem(auctionId, "shoes", "donor");
            _readStore.AddAuctionItem(auctionId, "shorts", "donor");

            var otherAuctionId = new AuctionId();

            _readStore.AddAuction(otherAuctionId);
            _readStore.AddAuctionItem(otherAuctionId, "nope", "bob");

            var viewModel = await _handler.HandleAsync(new GetAuctionItemsListQuery(auctionId));

            Assert.Equal(3, viewModel.Items.Length);
        }
Esempio n. 2
0
        public async Task WhenListIsQueriedThenPopulatesViewModelsFromReadModel()
        {
            var auctionId = new AuctionId();
            var auction   = _readStore.AddAuction(auctionId);

            _readStore.AddAuctionItem(auctionId, "other");
            _readStore.AddAuctionItem(auctionId, "three");
            _readStore.AddAuctionItem(auctionId, "one");

            var viewModel = await _handler.HandleAsync(new GetAuctionsListQuery());

            var auctionListItem = viewModel.Items[0];

            Assert.Equal(auction.Id, auctionListItem.Id);
            Assert.Equal(auction.Name, auctionListItem.Name);
            Assert.Equal(auction.AuctionDate, auctionListItem.AuctionDate);
            Assert.Equal(3, auctionListItem.ItemCount);
        }
Esempio n. 3
0
        public AuctionItemUpdatedEventHandlerTests()
        {
            _auctionId = new AuctionId();

            _readStore = new InMemoryReadStore();
            _readStore.AddAuction(_auctionId, "idk");
            _readStore.AddAuctionItem(_auctionId, "existing", "don", "what");

            _handler = new AuctionItemUpdatedEventHandler(_readStore);
        }
        public async Task WhenAuctionItemRemovedThenOnlyTheCorrectAuctionItemIsRemoved()
        {
            _readStore.AddAuctionItem(_auctionId, "something else");

            var @event = new AuctionItemRemovedEvent(_auctionId, "something else");

            await _handler.HandleAsync(@event);

            Assert.Single(_readStore.GetAll <AuctionItemReadModel>());
        }
        public AuctionItemRemovedEventHandlerTests()
        {
            _auctionId = new AuctionId();

            _readStore = new InMemoryReadStore();
            _readStore.AddAuction(_auctionId, "something");
            _readStore.AddAuctionItem(_auctionId, "idk");

            _handler = new AuctionItemRemovedEventHandler(_readStore);
        }