public void CreateViewResult() { // Arrange var mockDish = new Mock <IDishService>(); mockDish.Setup(repo => repo.GetDishes()); var controller = new DishesController(mockDish.Object); // Act var result = controller.Create(); // Assert Assert.IsType <ViewResult>(result); }
public void CreateNewDish_Success_Result() { var createNewDishRequestModel = new Create.Command(); Mediator.Setup(x => x.Send(It.IsAny <Create.Command>(), new CancellationToken())). ReturnsAsync(ResponseWrapper <Create> .GetInstance((int)HttpStatusCode.OK, null, true, null)); DishesController.SetMediatrForTest(Mediator.Object); //Action var result = DishesController.Create(createNewDishRequestModel); //Assert Assert.IsType <Task <ActionResult <ResponseWrapper <Create> > > >(result); }
public void CreateActionResult() { // Arrange var mockDish = new Mock <IDishService>(); mockDish.Setup(repo => repo.GetDishes()); var controller = new DishesController(mockDish.Object); var dish = new Dish(); IFormFile file = null; // Act var result = controller.Create(dish, file); // Assert Assert.IsType <RedirectToActionResult>(result); }