public async Task SelectService_ModelIsValid() { // Arrange using (context) { SelectedServiceViewModel selserViewModel = new SelectedServiceViewModel { idServicio = 1, numeroHab = 1 }; var controller = new ServiciosController(context); // Act var result = await controller.SelectService(selserViewModel); //Assert var viewResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal(viewResult.ActionName, "SetReservaServicio"); } }
public async Task SelectService_ModelIsNotValid() { // Arrange using (context) { SelectedServiceViewModel selserViewModel = new SelectedServiceViewModel { }; var controller = new ServiciosController(context); controller.ModelState.AddModelError("idServicio", "requerido"); controller.ModelState.AddModelError("numeroHab", "requerido"); // Act var result = await controller.SelectService(selserViewModel); //Assert var viewResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal(viewResult.ActionName, "Index"); Assert.Equal(viewResult.ControllerName, "Habitacions"); } }