Exemple #1
0
        public async Task CanFinWithCondition()
        {
            await sut.InsertAsync(new TestEntity("1") { Quantity = 10 });

            await sut.InsertAsync(new TestEntity("2") { Quantity = 11 });

            await sut.InsertAsync(new TestEntity("3") { Quantity = 12 });

            await sut.InsertAsync(new TestEntity("4") { Quantity = 13 });

            var list = (await sut.FindAllAsync(x => x.Quantity > 10 && x.Quantity < 13)).ToList();

            Assert.Collection(list, x => Assert.Equal("2", x.Id), x => Assert.Equal("3", x.Id));
        }
        //!! Please Ran integration tests only one by one otherwise it leads to EventStoreCommunicationException "Unable to access persistence layer"
        public async Task ShouldUpdateReadModel()
        {
            subscriber.Subscribe <ProductItemCreated>(async @event => await HandleAsync(productItemCreatedHandlers, @event));
            subscriber.Subscribe <ProductItemChanged>(async @event => await HandleAsync(productItemChangedHandlers, @event));
            subscriber.Subscribe <ProductPriceChanged>(async @event => await HandleAsync(productItemPriceChangedHandlers, @event));

            var ProductItem = new Product(DefaultProductItemId);

            string priceId = Guid.NewGuid().ToString();

            ProductItem.ChangeProductItem(Code, ImageSource, ProductUrl, Description);
            ProductItem.ChangeProductItem(null, null, null, updatedDescription);
            ProductItem.ChangeProductPrice(priceId, priceValue);
            await sut1.SaveAsync(ProductItem);

            var productReadModel = await productItemRepository.GetByIdAsync(DefaultProductItemId.ToString());

            var productPriceReadModel = await productItemPriceRepository.FindAllAsync(price => price.ItemId == DefaultProductItemId.ToString());

            Assert.Equal(productReadModel.Id, DefaultProductItemId.ToString());
            Assert.Equal(priceValue, productReadModel.Price);
            Assert.Equal(updatedDescription, productReadModel.Description);
            Assert.Equal(ImageSource, productReadModel.ImageSource);
            Assert.Equal(ProductUrl, productReadModel.ProductUrl);

            Assert.Equal(priceValue, productPriceReadModel.ToList().First().CurrentPrice);
        }