コード例 #1
0
        public async Task GetProductsReturnsAllProducts()
        {
            var options = new DbContextOptionsBuilder <ProductDbContext>().UseInMemoryDatabase(nameof(GetProductsReturnsAllProducts)).Options;

            var db = new ProductDbContext(options);

            CreateProducts(db);

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

            var mapper = new Mapper(configuration);

            var productsProvider = new ProductProvider(db, null, mapper);

            var res = await productsProvider.GetAllProductsAsync();

            Assert.True(res.IsSuccesss);

            Assert.True(res.Products.Any());

            Assert.Equal("", res.ErrorMessage);
        }