Ejemplo n.º 1
0
        public void CheckIfBrandExists()
        {
            DbContextOptions <NoodleContext> options =
                new DbContextOptionsBuilder <NoodleContext>()
                .UseInMemoryDatabase("CanCheckIfBrandExists")
                .Options;

            using (NoodleContext context = new NoodleContext(options))
            {
                //arrange
                Brand brand1 = new Brand();
                brand1.Name = "Nongshim";

                Brand brand2 = new Brand();
                brand2.Name = "Ottogi";

                Brand brand3 = new Brand();
                brand3.Name = "Samyang";

                BrandController bc = new BrandController(context);
                context.Brands.AddAsync(brand1);
                context.Brands.AddAsync(brand2);
                context.Brands.AddAsync(brand3);

                context.SaveChanges();

                //act
                var findBrand = bc.BrandExists("Nongshim");

                //assert
                Assert.True(findBrand);
            }
        }