示例#1
0
        public async Task GetProductsReturnsProductUsingInValidId()
        {
            var options = new DbContextOptionsBuilder <ProductsDbContext>()
                          .UseInMemoryDatabase(nameof(GetProductsReturnsProductUsingInValidId))
                          .Options;

            var dbContext = new ProductsDbContext(options);

            CreateProducts(dbContext);

            var productprofile = new ProductProfile();

            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(productprofile));

            var mapper = new Mapper(configuration);

            var productsProvider = new ProductsProvider(dbContext, null, mapper);

            var product = await productsProvider.GetProductByIdAsync(-1);

            Assert.False(product.IsSuccess);

            Assert.Null(product.Product);

            Assert.NotNull(product.ErrorMessage);
        }