public void ReturnsMarcarComoTerminadoTest() { 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.MarcarComoTerminado(1); Assert.IsInstanceOf <RedirectToRouteResult>(view); }
public void MarcarComoTerminadoIsOk() { 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()); var controller = new BibliotecaController(authManagerMock.Object, bibliotecaServiceMock.Object); var result = controller.MarcarComoTerminado(1); Assert.IsInstanceOf <RedirectToRouteResult>(result); }
public void MarcarComoTerminadoNull() { 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.MarcarComoTerminado(1) as RedirectToRouteResult; var valor = controller.TempData; Assert.IsNotNull(valor["SuccessMessage"]); Assert.IsInstanceOf <RedirectToRouteResult>(view); }
public void MarcarComoTerminado() { 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.MarcarComoTerminado(1); Assert.IsInstanceOf <RedirectToRouteResult>(view); }