public async Task ListServicesID_Ocupada() { // Arrange using (context) { Habitacion hab = await context.Habitacion.SingleOrDefaultAsync <Habitacion>(m => m.numero == 1); ICollection <Servicio> listServices = await context.Servicio.ToListAsync(); ListSolicitarServicioViewModel expectedModel = new ListSolicitarServicioViewModel { numeroHab = hab.numero, ListaServicios = listServices, ocupada = hab.ocupada }; var controller = new ServiciosController(context); // Act var result = await controller.ListServices(1); //Assert var viewResult = Assert.IsType <ViewResult>(result); ListSolicitarServicioViewModel model = (result as ViewResult).Model as ListSolicitarServicioViewModel; var expectedListServices = model.ListaServicios.ToList(); Assert.Equal(expectedModel, model, Comparer.Get <ListSolicitarServicioViewModel>((p1, p2) => p1.numeroHab == p2.numeroHab && p1.ocupada == p2.ocupada)); Assert.Equal(expectedListServices, listServices, Comparer.Get <Servicio>((p1, p2) => p1.idServicio == p2.idServicio)); } }
public async Task ListServices_NoOcupada() { // Arrange using (context) { var controller = new ServiciosController(context); // Act var result = await controller.ListServices(2); //Assert var viewResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal(viewResult.ControllerName, "Habitacions"); Assert.Equal(viewResult.ActionName, "Index"); } }