Beispiel #1
0
        public async void ShouldCallQueryWithInvalidIdAndReturnNull()
        {
            var query = new FindProductByIdQuery(Guid.NewGuid());
            IQueryHandler <FindProductByIdQuery, ProductInfo> handler = new FindProductByIdQueryHandler(productRepository);
            var productInfo = await handler.ExecuteAsync(query);

            Assert.Null(productInfo);
        }
Beispiel #2
0
        public async void ShouldCreateProductCallQueryAndReturnProductInfo()
        {
            var product = new Product(Guid.NewGuid(), "Code", "Name");
            await productRepository.Save(product);

            var query = new FindProductByIdQuery(product.Id);
            IQueryHandler <FindProductByIdQuery, ProductInfo> handler = new FindProductByIdQueryHandler(productRepository);
            var productInfo = await handler.ExecuteAsync(query);

            Assert.NotNull(productInfo);
            Assert.Equal(productInfo.Id, product.Id);
            Assert.Equal(productInfo.Code, product.Code);
            Assert.Equal(productInfo.Name, product.Name);
            Assert.Contains(product.Code, productInfo.FullDescription);
            Assert.Contains(product.Name, productInfo.FullDescription);
        }