public void CrearExamen_CrearPostTest()
        {
            var examem = new Examen {
                Id = 1, TemaId = 1, UsuarioId = 1, FechaCreacion = DateTime.Now
            };
            var faker = new Mock <IExamenService>();

            faker.Setup(a => a.ObtenerListaTemas()).Returns(new List <Tema>
            {
                new Tema {
                    Id = 1, Nombre = "La guerra", Descripcion = "Esta guerra se dio en el año 2000"
                },
                new Tema {
                    Id = 2, Nombre = "La guerra1", Descripcion = "Esta guerra se dio en el año 2001"
                }
            });
            faker.Setup(a => a.GenerarPreguntas(1, 2)).Returns(new List <Pregunta>
            {
                new Pregunta {
                    Id = 1, TemaId = 1, Descripcion = "Pregunta 1"
                },
                new Pregunta {
                    Id = 2, TemaId = 1, Descripcion = "Pregunta 2"
                },
            });
            var controller = new ExamenController(faker.Object);
            var view       = controller.Crear(examem, 2);

            Assert.IsInstanceOf <RedirectToRouteResult>(view);
        }
Exemplo n.º 2
0
        public void DebePoderRetonarUnaListadeExamenes()
        {
            var examen = new Mock <IExamene>();
            var usario = new Mock <IUsuario>();

            Usuario usuario = new Usuario()
            {
                Id       = 1,
                Nombres  = "Ana",
                Password = "******",
                Username = "******"
            };

            Examen examens = new Examen()
            {
                Id         = 1,
                TemaId     = 1,
                UsuarioId  = 1,
                EstaActivo = true,
            };


            usario.Setup(a => a.setNombreUsuario()).Returns(usuario);
            examen.Setup(a => a.ExamenesUser(usuario)).Returns(new List <Examen>());

            var controller = new ExamenController(usario.Object, examen.Object, null);

            var view = controller.Index() as ViewResult;


            Assert.IsInstanceOf <List <Examen> >(view.Model);
            Assert.IsInstanceOf <ViewResult>(view);
        }
Exemplo n.º 3
0
 public FormSeleccionarExamen()
 {
     InitializeComponent();
     controller = new ExamenController();
     agregarPropiedadesAutoSizing();
     loadData();
     updateControlesPaginado();
 }
Exemplo n.º 4
0
        public void TestNOtNullCrearPOST()
        {
            var mocky = new Mock <IExamenService>();

            mocky.Setup(a => a.GetTemas()).Returns(new List <Tema>());
            mocky.Setup(a => a.AddExamenPregunta(new ExamenPregunta()));
            mocky.Setup(a => a.AddExamenPregunta(new ExamenPregunta()));
            var controller = new ExamenController(mocky.Object);
        }
Exemplo n.º 5
0
        public void IdDetalleExamenNoValidoResultPaginaError()
        {
            //Arrange
            ExamenController controller = new ExamenController();
            //Act
            ViewResult result = controller.Details(-1) as ViewResult;

            //Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 6
0
        public void IdDeleteNoValidoResultView()
        {
            //Arragne
            ExamenController controller = new ExamenController();
            //Act
            ViewResult result = controller.Delete(-5) as ViewResult;

            //Asert
            Assert.IsNotNull(result);
        }
Exemplo n.º 7
0
        public void IndexViewResultIsNotNull()
        {
            // Arrange
            ExamenController controller = new ExamenController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 8
0
        public void TestExamenCrear()
        {
            var serviceSessionMock   = new Mock <ISessionService>();
            var serviceExamenMock    = new Mock <IExamenService>();
            var serviceTemasMock     = new Mock <ITemasServices>();
            var servicePreguntasMock = new Mock <IPreguntasService>();

            var controlador = new ExamenController(serviceSessionMock.Object, serviceExamenMock.Object, serviceTemasMock.Object, servicePreguntasMock.Object);
            var vista       = controlador.Crear();

            Assert.IsInstanceOf <ViewResult>(vista);
        }
Exemplo n.º 9
0
        public void GetCrearIsOK()
        {
            var AuthManagerMock     = new Mock <IAuthManager>();
            var examenServiceMock   = new Mock <IExamenService>();
            var TemaServiceMock     = new Mock <ITemaService>();
            var PreguntaServiceMock = new Mock <IPreguntasService>();

            var controllerExamen = new ExamenController(AuthManagerMock.Object, examenServiceMock.Object, TemaServiceMock.Object, PreguntaServiceMock.Object);
            var result           = controllerExamen.Crear();

            Assert.IsInstanceOf <ViewResult>(result);
        }
Exemplo n.º 10
0
        public void TestNOtNullCrearGet()
        {
            var mocky = new Mock <IExamenService>();

            mocky.Setup(a => a.GetTemas()).Returns(new List <Tema>());
            var controller = new ExamenController(mocky.Object);
            var view       = (ViewResult)controller.Crear();

            Assert.IsNotNull(view.Model);
            Assert.IsInstanceOf <Examen>(view.Model);
            Assert.IsNotNull(view.ViewBag.Temas);
            Assert.IsInstanceOf <List <Tema> >(view.ViewBag.Temas);
        }
Exemplo n.º 11
0
        public void FechaAnteriorAHoyResultView()
        {
            //Arrange
            ExamenController controller = new ExamenController();
            //Act
            var examen = new EXAMan()
            {
                Fecha = new DateTime(2019, 08, 22)
            };
            ViewResult result = controller.Create(examen) as ViewResult;

            //Assert
            Assert.IsNotNull(result);
        }
Exemplo n.º 12
0
        public void TestExamenIndex()
        {
            var serviceSessionMock   = new Mock <ISessionService>();
            var serviceExamenMock    = new Mock <IExamenService>();
            var serviceTemasMock     = new Mock <ITemasServices>();
            var servicePreguntasMock = new Mock <IPreguntasService>();

            serviceSessionMock.Setup(o => o.ConvertirSessionIdAIntId()).Returns(1);
            serviceExamenMock.Setup(o => o.GetExamenByUserId(1)).Returns(new List <Examen>());

            var controlador = new ExamenController(serviceSessionMock.Object, serviceExamenMock.Object, serviceTemasMock.Object, servicePreguntasMock.Object);
            var vista       = controlador.Index();

            Assert.IsInstanceOf <ViewResult>(vista);
        }
Exemplo n.º 13
0
        public void GetIndexIsOK()
        {
            var AuthManagerMock = new Mock <IAuthManager>();

            AuthManagerMock.Setup(x => x.GetUserLogueado()).Returns(new Usuario());
            var examenServiceMock = new Mock <IExamenService>();
            //examenServiceMock.Setup(x => x.GetExamensByUserId(1)).Returns(new List<Examen>());
            var TemaServiceMock     = new Mock <ITemaService>();
            var PreguntaServiceMock = new Mock <IPreguntasService>();

            var controllerExamen = new ExamenController(AuthManagerMock.Object, examenServiceMock.Object, TemaServiceMock.Object, PreguntaServiceMock.Object);
            var result           = controllerExamen.Index();

            Assert.IsInstanceOf <ViewResult>(result);
        }
        public void RetornarListaExamenes()
        {
            var exmanesMock = new Mock <IExamen>();
            var uasuaio     = new Mock <IUsuario>();

            uasuaio.Setup(a => a.SetNombreUsuario()).Returns(new Usuario {
                Id = 3
            });

            exmanesMock.Setup(a => a.getListaExanes(0)).Returns(new List <Examen>());

            var controller = new ExamenController(exmanesMock.Object, null, null, uasuaio.Object);

            var view = controller.Index() as ViewResult;

            Assert.IsInstanceOf <ViewResult>(view);
        }
        public void CrearExamenEnviandoNull_CrearPostTest()
        {
            var faker = new Mock <IExamenService>();

            faker.Setup(a => a.ObtenerListaTemas()).Returns(new List <Tema>
            {
                new Tema {
                    Id = 1, Nombre = "La guerra", Descripcion = "Esta guerra se dio en el año 2000"
                },
                new Tema {
                    Id = 2, Nombre = "La guerra1", Descripcion = "Esta guerra se dio en el año 2001"
                }
            });
            var controller = new ExamenController(faker.Object);
            var view       = controller.Crear(null, 3);

            Assert.IsInstanceOf <ViewResult>(view);
        }
        public void Contenido_DelViewBagTemas_CrearTest()
        {
            var faker = new Mock <IExamenService>();

            faker.Setup(a => a.ObtenerListaTemas()).Returns(new List <Tema>
            {
                new Tema {
                    Id = 1, Nombre = "La guerra", Descripcion = "Esta guerra se dio en el año 2000"
                },
                new Tema {
                    Id = 2, Nombre = "La guerra1", Descripcion = "Esta guerra se dio en el año 2001"
                }
            });

            var controller = new ExamenController(faker.Object);
            var view       = controller.Crear() as ViewResult;

            Assert.IsInstanceOf <List <Tema> >(view.ViewBag.Temas);
        }
Exemplo n.º 17
0
        public void PostCrearIsOK()
        {
            Examen examen = new Examen();
            var    temp   = new Usuario()
            {
                Id = 1,
            };
            var AuthManagerMock     = new Mock <IAuthManager>();
            var examenServiceMock   = new Mock <IExamenService>();
            var TemaServiceMock     = new Mock <ITemaService>();
            var PreguntaServiceMock = new Mock <IPreguntasService>();

            AuthManagerMock.Setup(e => e.GetUserLogueado()).Returns(temp);
            PreguntaServiceMock.Setup(x => x.GetPreguntas(1, 1)).Returns(new List <Pregunta>());
            var controllerExamen = new ExamenController(AuthManagerMock.Object, examenServiceMock.Object, TemaServiceMock.Object, PreguntaServiceMock.Object);
            var result           = controllerExamen.Crear(examen, 1);

            Assert.IsInstanceOf <RedirectToRouteResult>(result);
        }
Exemplo n.º 18
0
        public void TestExamenCrearForm()
        {
            var serviceSessionMock   = new Mock <ISessionService>();
            var serviceExamenMock    = new Mock <IExamenService>();
            var serviceTemasMock     = new Mock <ITemasServices>();
            var servicePreguntasMock = new Mock <IPreguntasService>();

            servicePreguntasMock.Setup(o => o.GenerarPreguntas(1, 2)).Returns(new List <Pregunta>());

            var controlador = new ExamenController(serviceSessionMock.Object, serviceExamenMock.Object, serviceTemasMock.Object, servicePreguntasMock.Object);
            var vista       = controlador.Crear(new Examen {
                Id            = 1,
                FechaCreacion = new DateTime(1996, 06, 06),
                EstaActivo    = true,
                TemaId        = 1,
                UsuarioId     = 1
            }, 2);

            Assert.IsInstanceOf <RedirectToRouteResult>(vista);
        }
        public void CuantosTemasContieneElViewBagTemas_CrearTest()
        {
            var faker = new Mock <IExamenService>();

            faker.Setup(a => a.ObtenerListaTemas()).Returns(new List <Tema>
            {
                new Tema {
                    Id = 1, Nombre = "La guerra", Descripcion = "Esta guerra se dio en el año 2000"
                },
                new Tema {
                    Id = 2, Nombre = "La guerra1", Descripcion = "Esta guerra se dio en el año 2001"
                }
            });

            var controller = new ExamenController(faker.Object);
            var view       = controller.Crear() as ViewResult;
            var model      = view.ViewBag.Temas as List <Tema>;

            Assert.AreEqual(2, model.Count());
        }
        public void LaVistaRetornaViewResult_IndexTest()
        {
            var faker = new Mock <IExamenService>();

            faker.Setup(a => a.GetLoggedUser()).Returns(new Usuario {
                Id = 1, Username = "******", Password = "******", Nombres = "Administrador"
            });
            faker.Setup(a => a.ObtenerListaExamenes()).Returns(new List <Examen>
            {
                new Examen {
                    Id = 1, TemaId = 1, UsuarioId = 1, FechaCreacion = DateTime.Now
                },
                new Examen {
                    Id = 2, TemaId = 2, UsuarioId = 2, FechaCreacion = DateTime.Now
                }
            });

            var controller = new ExamenController(faker.Object);
            var view       = controller.Index() as ViewResult;

            Assert.IsInstanceOf <ViewResult>(view);
        }
        public void Cuantos_Examenes_TieneElUsuario()
        {
            var faker = new Mock <IExamenService>();

            faker.Setup(a => a.GetLoggedUser()).Returns(new Usuario {
                Id = 1, Username = "******", Password = "******", Nombres = "Administrador"
            });
            faker.Setup(a => a.ObtenerListaExamenes()).Returns(new List <Examen>
            {
                new Examen {
                    Id = 1, TemaId = 1, UsuarioId = 1, FechaCreacion = DateTime.Now, EstaActivo = true
                },
                new Examen {
                    Id = 2, TemaId = 2, UsuarioId = 2, FechaCreacion = DateTime.Now, EstaActivo = true
                }
            });

            var controller = new ExamenController(faker.Object);
            var view       = controller.Index() as ViewResult;
            var model      = view.Model as List <Examen>;

            Assert.AreEqual(1, model.Count());
        }