Ejemplo n.º 1
0
        public async void TestGetDishByName()
        {
            //Arrange

            IRestaurantService restaurantService = new FakeRestaurantService();
            DishController     dishController    = new(restaurantService);
            string             name = "Couscous";

            //string noName = "NoName";

            //Act
            //Test sur id = 1
            OkObjectResult dishActionResult1 = await dishController.GetDishByName(name) as OkObjectResult;

            //Test sur Résultat n'existe pas :
            //NotFoundResult notFounddishActionResult = await dishController.GetDishByName(noName) as NotFoundResult;


            //Assert
            Assert.NotNull(dishActionResult1);
            Assert.Equal(200, dishActionResult1.StatusCode);

            //Assert.NotNull(notFounddishActionResult);
            //Assert.Equal(404, notFounddishActionResult.StatusCode);
        }
Ejemplo n.º 2
0
        public async void TestCreateBooking()
        {
            //Arange
            IRestaurantService restaurantService = new FakeRestaurantService();
            BookingController  bookingController = new(restaurantService);
            Booking            firstFakeBooking  = new()
            {
                Id          = 1,
                BookingDate = DateTime.Now,
                MealNumber  = 1,
                Starter     = 1,
                MainCourse  = 1,
                Dessert     = 1,
                Id_Client   = 1,
                Id_Service  = 1
            };

            //Act

            var firstFakeBookingActionResult = await bookingController.CreateBooking(firstFakeBooking);

            //Assert
            Assert.NotNull(firstFakeBookingActionResult);
        }
    }
Ejemplo n.º 3
0
        public async void TestGetAllMenu()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            MenuController     menuController    = new(restaurantService);
            //Act
            ActionResult <List <Menu> > MenuActionResult = await menuController.GetAllMenu();

            //Assert
            Assert.NotNull(MenuActionResult);
        }
Ejemplo n.º 4
0
        public async void TestGetAllService()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            ServiceController  serviceController = new(restaurantService);
            //Act
            ActionResult <List <Service> > ServiceActionResult = await serviceController.GetAllService();

            //Assert
            Assert.NotNull(ServiceActionResult);
        }
Ejemplo n.º 5
0
        public async void TestGetAllDish()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            DishController     dishController    = new(restaurantService);
            //Act
            ActionResult <List <Dish> > DishActionResult = await dishController.GetAllDish();

            //Assert
            Assert.NotNull(DishActionResult);
        }
Ejemplo n.º 6
0
        public async void TestRemoveIngredientById()
        {
            //Arrange
            IRestaurantService    restaurantService     = new FakeRestaurantService();
            IngredientsController ingredientsController = new(restaurantService);

            //Act
            var noContentExpected = await ingredientsController.DeleteIngredient(1) as NoContentResult;

            //Assert
            Assert.NotNull(noContentExpected);
            Assert.Equal(204, noContentExpected.StatusCode);
        }
Ejemplo n.º 7
0
        public async void GetAll()
        {
            //Arrange
            IRestaurantService    restaurantService    = new FakeRestaurantService();
            IngredientsController ingredientController = new (restaurantService);



            //Act
            ActionResult <List <Ingredients> > IngredientsActionResult = await ingredientController.GetAll();

            //Assert
            Assert.NotNull(IngredientsActionResult);
        }
Ejemplo n.º 8
0
        public async void TestCreateMenu()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            MenuController     menuController    = new(restaurantService);
            Menu firstMenu = new();
            {
                firstMenu.Year       = DateTime.Parse("01/01/2021");
                firstMenu.WeekNumber = 1;
            }
            //Act
            var firstMenuActionResult = await menuController.CreateMenu(firstMenu);

            //Assert
            Assert.NotNull(firstMenuActionResult);
        }
Ejemplo n.º 9
0
        public async void TestGetMenuById()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            MenuController     menuController    = new(restaurantService);
            //Act
            OkObjectResult menuActionResult = await menuController.GetMenuById(1) as OkObjectResult;

            NotFoundResult notFoundMenuActionResult = await menuController.GetMenuById(9999) as NotFoundResult;

            //Assert
            Assert.NotNull(menuActionResult);
            Assert.Equal(200, menuActionResult.StatusCode);
            Assert.NotNull(notFoundMenuActionResult);
            Assert.Equal(404, notFoundMenuActionResult.StatusCode);
        }
Ejemplo n.º 10
0
        public async void TestCreateIngredient()
        {
            //Arange
            IRestaurantService    restaurantService     = new FakeRestaurantService();
            IngredientsController ingredientsController = new(restaurantService);
            Ingredients           salt = new();
            {
                salt.Name  = "Salt";
                salt.Price = 1.5m;
            }
            //Act
            var saltIngredientActionResult = await ingredientsController.CreateIngredient(salt);

            //Assert
            Assert.NotNull(saltIngredientActionResult);
        }
Ejemplo n.º 11
0
        public async void TestCreateService()
        {
            //Arange
            IRestaurantService restaurantService = new FakeRestaurantService();
            ServiceController  serviceController = new(restaurantService);
            Service            service           = new();
            {
                service.ServiceNumber = 1;
                service.DateService   = DateTime.Now;
            }
            //Act
            var serviceActionResult = await serviceController.CreateService(service);

            //Assert
            Assert.NotNull(serviceActionResult);
        }
Ejemplo n.º 12
0
        public async void TestCreateDish()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            DishController     dishController    = new(restaurantService);
            Dish tabbouleh = new();
            {
                tabbouleh.Name       = "Tabbouleh";
                tabbouleh.Popularity = 0;
            }
            //Act
            var tabboulehDishActionResult = await dishController.CreateDish(tabbouleh);

            //Assert
            Assert.NotNull(tabboulehDishActionResult);
        }
        public async void TestCreateListOfIngredient()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            ListOfIngredientController listOfIngredientController = new(restaurantService);
            ListOfIngredient fakeIdDishAndfakeIdIngredient = new();
            {
                fakeIdDishAndfakeIdIngredient.IdDish = 1;
                fakeIdDishAndfakeIdIngredient.IdIngredient = 2;
                fakeIdDishAndfakeIdIngredient.Quantity = 1;
            }
            //Act
            var fakeListOfIngredientActionResult = await listOfIngredientController.CreateListOfIngredient(fakeIdDishAndfakeIdIngredient);

            //Assert
            Assert.NotNull(fakeListOfIngredientActionResult);
        }
Ejemplo n.º 14
0
        public async void TestModifyIngredient()
        {
            //Arrange
            IRestaurantService    restaurantService     = new FakeRestaurantService();
            IngredientsController ingredientsController = new(restaurantService);

            Ingredients salt = new();
            {
                salt.Name  = "Salt";
                salt.Price = 1.5m;
            }

            Ingredients salt2 = new ()

            {
                Id    = 105,
                Name  = "Salt",
                Price = 1.5m
            };
            Ingredients saltGood = new ()
            {
                Id    = 1,
                Name  = "Salt",
                Price = 1.5m
            };
            //Act
            var IngredientActionResult = await ingredientsController.ModifyIngredient(1, salt) as BadRequestResult;

            var IngredientActionResultNull = await ingredientsController.ModifyIngredient(1, null) as BadRequestResult;

            var IngredientActionResultNotFoundCase = await ingredientsController.ModifyIngredient(105, salt2) as NotFoundResult;

            var IngredientActionResultOkCase = await ingredientsController.ModifyIngredient(1, saltGood) as OkObjectResult;

            //Assert
            Assert.NotNull(IngredientActionResult);
            Assert.NotNull(IngredientActionResultNull);
            Assert.NotNull(IngredientActionResultNotFoundCase);
            Assert.NotNull(IngredientActionResultOkCase);
        }

        /// <summary>
        /// Test Unitaire sur Get All
        /// </summary>
        [Fact]
Ejemplo n.º 15
0
        public async void TestModifyDish()
        {
            //Arrange
            IRestaurantService restaurantService = new FakeRestaurantService();
            DishController     dishController    = new(restaurantService);

            Dish tabbouleh = new();
            {
                tabbouleh.Name       = "Tabbouleh";
                tabbouleh.Popularity = 0;
            }

            Dish couscous = new()

            {
                Id         = 105,
                Name       = "Couscous",
                Popularity = 1
            };
            Dish couscousGood = new()
            {
                Id         = 1,
                Name       = "Couscous",
                Popularity = 1
            };
            //Act
            var DishActionResult = await dishController.ModifyDish(1, tabbouleh) as BadRequestResult;

            var DishActionResultNull = await dishController.ModifyDish(1, null) as BadRequestResult;

            var DishActionResultNotFoundCase = await dishController.ModifyDish(105, couscous) as NotFoundResult;

            var DishActionResultOkCase = await dishController.ModifyDish(1, couscousGood) as OkObjectResult;

            //Assert
            Assert.NotNull(DishActionResult);
            Assert.NotNull(DishActionResultNull);
            Assert.NotNull(DishActionResultNotFoundCase);
            Assert.NotNull(DishActionResultOkCase);
        }
    }
}
Ejemplo n.º 16
0
        public async void TestGetIngredientById()
        {
            //Arrange
            IRestaurantService    restaurantService     = new FakeRestaurantService();
            IngredientsController ingredientsController = new(restaurantService);

            //Act
            //Test sur id = 1
            OkObjectResult ingredientActionResult1 = await ingredientsController.GetIngredientById(1) as OkObjectResult;

            //Test sur Résultat n'existe pas :
            NotFoundResult notFoundingredientActionResult = await ingredientsController.GetIngredientById(9999) as NotFoundResult;


            //Assert
            Assert.NotNull(ingredientActionResult1);
            Assert.Equal(200, ingredientActionResult1.StatusCode);
            Assert.NotNull(notFoundingredientActionResult);
            Assert.Equal(404, notFoundingredientActionResult.StatusCode);
        }