public async Task Detail_withIdNoExist() { // Arrange using (context) { var controller = new HabitacionsController(context); // Act var result = await controller.Details(20); //Assert var viewResult = Assert.IsType <NotFoundResult>(result); } }
public async Task Detail_withIdExist() { // Arrange using (context) { Habitacion expectedModel = new Habitacion { numero = 1, ocupada = true, aforo = 1, descripcion = "", localizacion = "", precio = 1 }; var controller = new HabitacionsController(context); // Act var result = await controller.Details(1); //Assert var viewResult = Assert.IsType <ViewResult>(result); Habitacion model = (result as ViewResult).Model as Habitacion; Assert.Equal(expectedModel, model, Comparer.Get <Habitacion>((p1, p2) => p1.numero == p2.numero)); } }
public async Task IndexOcupadaTrue() { // Arrange using (context) { IEnumerable <Habitacion> expectedModel = new Habitacion[2] { new Habitacion { numero = 1, ocupada = true, aforo = 1, descripcion = "", localizacion = "", precio = 1 }, new Habitacion { numero = 2, ocupada = false, aforo = 1, descripcion = "", localizacion = "", precio = 1 } }; var controller = new HabitacionsController(context); // Act var result = await controller.Index(true); //Assert var viewResult = Assert.IsType <ViewResult>(result); IEnumerable <Habitacion> model = (result as ViewResult).Model as IEnumerable <Habitacion>; Assert.Equal(expectedModel, model, Comparer.Get <Habitacion>((p1, p2) => p1.numero == p2.numero)); } }