public async Task Create_RouteTypeInvalidInput_RedirectToActionCreateHall() { // Arrange var mockService = new Mock <IHallService>(); HallController controller = new HallController(mockService.Object); var hallListViewModel = new HallCreateViewModel { Name = "boulder", Type = (RouteType)4 }; // Act var result = await controller.Create(hallListViewModel); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Hall", redirectToActionResult.ControllerName); Assert.Equal("Create", redirectToActionResult.ActionName); mockService.Verify(service => service.AddHall(It.IsAny <string>(), It.IsAny <RouteType>()), Times.Never); }
public void List_RouteHall_ReturnViewModel() { // Arrange var mockService = new Mock <IHallService>(); mockService.Setup(service => service.GetActiveHalls()) .Returns(new List <RouteHall> { new RouteHall(), new RouteHall() }); HallController controller = new HallController(mockService.Object); // Act var result = controller.Create(); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <HallCreateViewModel>( viewResult.ViewData.Model); Assert.Equal(2, model.Halls.Count); }