public void ReturnsMarcarComoLeyendolTest() { 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.MarcarComoLeyendo(1); Assert.IsInstanceOf <RedirectToRouteResult>(view); }
public void MarcarComoLeyendoNull() { var mock = new Mock <IBibliotecaService>(); mock.Setup(a => a.BibliotecaFindLibroIdyUsuarioId(1, 1)).Returns(new Biblioteca()); mock.Setup(a => a.SaveChanges()); var controller = new BibliotecaController(mock.Object); var view = controller.MarcarComoLeyendo(1) as RedirectToRouteResult; var valor = controller.TempData; Assert.IsNotNull(valor["SuccessMessage"]); Assert.IsInstanceOf <RedirectToRouteResult>(view); }
public void MarcarComoLeyendo() { var user = new Mock <IUsuario>(); var listbi = new Mock <IBiblioteca>(); Usuario usuario = new Usuario() { Id = 1, Nombres = "Anais", Password = "******", Username = "******" }; user.Setup(s => s.setNombreUsuario()).Returns(usuario); listbi.Setup(a => a.GetBibliotecas(usuario)).Returns(new List <Biblioteca>()); var listaBi = new BibliotecaController(listbi.Object, user.Object); var view = listaBi.MarcarComoLeyendo(1); Assert.IsInstanceOf <RedirectToRouteResult>(view); }
public void MarcarComoLeyendoIsOkx() { var authManagerMock = new Mock <IAuthManager>(); var bibliotecaServiceMock = new Mock <IBibliotecaService>(); authManagerMock.Setup(x => x.GetUserLogueado()).Returns(new Usuario()); bibliotecaServiceMock.Setup(x => x.GetBibliotecaByLibroidAndUserid(1, new Usuario())).Returns(new Biblioteca()); bibliotecaServiceMock.Setup(x => x.CambiarEstadoLeyendo(new Biblioteca())); var controller = new BibliotecaController(authManagerMock.Object, bibliotecaServiceMock.Object); var result = controller.MarcarComoLeyendo(1); //var libro = bibliotecaService.GetBibliotecaByLibroidAndUserid(libroId, user); //bibliotecaService.CambiarEstadoLeyendo(libro); Assert.IsInstanceOf <RedirectToRouteResult>(result); }