Ejemplo n.º 1
0
        public void Test2(int id)
        {
            Brand         b      = new Brand();
            IActionResult result = controller.Create();

            Assert.NotNull(result);
        }
Ejemplo n.º 2
0
        public async void CanCreateNewBrand()
        {
            DbContextOptions <NoodleContext> options =
                new DbContextOptionsBuilder <NoodleContext>()
                .UseInMemoryDatabase("CanCreateNewBrand")
                .Options;

            using (NoodleContext context = new NoodleContext(options))
            {
                //arrange
                Brand brand = new Brand
                {
                    Name    = "Mi Goreng",
                    Country = "Indonesia"
                };
                BrandController bc = new BrandController(context);

                //act
                await context.AddAsync(brand);

                await context.SaveChangesAsync();

                var addedBrand = bc.Create(brand);

                var results = context.Brands.Where(x => x.Name == "Mi Goreng");

                //assert
                Assert.Equal(1, results.Count());
            }
        }
Ejemplo n.º 3
0
        public void CreateTestReturn200()
        {
            FormModel formModel = new()
            {
                Name = "Test3"
            };

            var result = brandController.Create(formModel);

            Assert.IsInstanceOf <OkObjectResult>(result.Result);
        }