public void ReturnsIndexModelTest() { var faker = new Mock <IBibliotecaService>(); faker.Setup(a => a.ObtenerUsuarioLogueado()).Returns(new Usuario { Id = 1, Username = "******", Password = "******", Nombres = "Jose" }); faker.Setup(a => a.ObteberListaBibliotecas()).Returns(new List <Biblioteca> { new Biblioteca { Id = 1, UsuarioId = 1, LibroId = 1 }, new Biblioteca { Id = 2, UsuarioId = 1, LibroId = 2 }, new Biblioteca { Id = 3, UsuarioId = 3, LibroId = 3 } }); var controller = new BibliotecaController(faker.Object); var view = controller.Index() as ViewResult; Assert.IsInstanceOf <List <Biblioteca> >(view.Model); }
public void ContarBibliotecasDeUnUsuarioTest() { var faker = new Mock <IBibliotecaService>(); faker.Setup(a => a.ObtenerUsuarioLogueado()).Returns(new Usuario { Id = 1, Username = "******", Password = "******", Nombres = "Jose" }); faker.Setup(a => a.ObteberListaBibliotecas()).Returns(new List <Biblioteca> { new Biblioteca { Id = 1, UsuarioId = 1, LibroId = 1 }, new Biblioteca { Id = 2, UsuarioId = 1, LibroId = 2 }, new Biblioteca { Id = 3, UsuarioId = 3, LibroId = 3 } }); var controller = new BibliotecaController(faker.Object); var view = controller.Index() as ViewResult; var model = view.Model as List <Biblioteca>; Assert.AreEqual(2, model.Count); }
public void GetIndexBibliotecaIsOk() { var authManagerMock = new Mock <IAuthManager>(); var bibliotecaServiceMock = new Mock <IBibliotecaService>(); var controller = new BibliotecaController(authManagerMock.Object, bibliotecaServiceMock.Object); var result = controller.Index(); Assert.IsInstanceOf <ViewResult>(result); }
public void probarIndexObtenerListaReproduccionUsuario() { var idUsuario = 2; var mock = new Mock <IBibliotecaService>(); mock.Setup(o => o.obtenerListaReproduccionUsuario(idUsuario)); var controller = new BibliotecaController(mock.Object); var result = controller.Index(idUsuario) as ViewResult; Assert.IsInstanceOf <ViewResult>(result); mock.Verify(o => o.obtenerListaReproduccionUsuario(idUsuario), Times.AtLeastOnce); }
public void testIndexnotNull() { var mock = new Mock <IBibliotecaService>(); mock.Setup(a => a.bibliotecaWithLibroUsuario(1)).Returns(new List <Biblioteca>() { new Biblioteca(), new Biblioteca(), }); var controller = new BibliotecaController(mock.Object); var view = controller.Index() as ViewResult; var modelo = (List <Biblioteca>)view.Model; Assert.AreEqual(modelo.Count, 2); Assert.IsInstanceOf <List <Biblioteca> >(view.Model); Assert.IsNotNull(view); }
public void ListBiblioteca() { var user = new Mock <IUsuario>(); var list = new Mock <IBiblioteca>(); Usuario usuario = new Usuario() { Id = 1, Nombres = "Anais", Password = "******", Username = "******" }; user.Setup(s => s.setNombreUsuario()).Returns(usuario); list.Setup(a => a.GetBibliotecas(usuario)).Returns(new List <Biblioteca>()); var listaBi = new BibliotecaController(list.Object, user.Object); var view = listaBi.Index() as ViewResult; Assert.IsInstanceOf <ViewResult>(view); }