Beispiel #1
0
        public void ObtenerPuntosCategoriaElementosNoValido()
        {
            string nombre               = "Este";
            string descripcion          = "Prueba";
            var    repoMock             = new Mock <IRepository <PuntoTuristico> >(MockBehavior.Strict);
            var    repoLogicaCat        = new Mock <ICategoria>(MockBehavior.Strict);
            PuntoTuristico_Logic logica = new PuntoTuristico_Logic(repoMock.Object, repoLogicaCat.Object);
            PuntoTuristico       punto  = logica.PuntoTuristico(nombre, descripcion);

            punto.Id = 1;
            PuntoTuristico punto2 = logica.PuntoTuristico(nombre + "2", descripcion + "2");

            punto.Id = 2;

            Categoria categoria = new Categoria()
            {
                Id     = 0,
                Nombre = "Playa"
            };
            PuntoTuristicoCategoria ptc = new PuntoTuristicoCategoria()
            {
                Categoria        = categoria,
                CategoriaId      = categoria.Id,
                PuntoTuristico   = punto,
                PuntoTuristicoId = punto.Id
            };
            Categoria categoria2 = new Categoria()
            {
                Id     = 2,
                Nombre = "Playa"
            };
            PuntoTuristicoCategoria ptc2 = new PuntoTuristicoCategoria()
            {
                Categoria        = categoria2,
                CategoriaId      = categoria2.Id,
                PuntoTuristico   = punto2,
                PuntoTuristicoId = punto2.Id
            };

            punto.PuntosTuristicosCategoria.Add(ptc);
            punto2.PuntosTuristicosCategoria.Add(ptc2);
            List <PuntoTuristico> lista = new List <PuntoTuristico>();

            lista.Add(punto);
            lista.Add(punto2);
            int[] idCat = { 1 };
            List <PuntoTuristico> resultado = logica.PuntosPorCategoria(lista, idCat);

            Assert.AreEqual(0, resultado.Count);
        }
Beispiel #2
0
        public void AgregarPuntosCategoriaOK()
        {
            string nombre               = "Este";
            string descripcion          = "Prueba";
            var    repoMock             = new Mock <IRepository <PuntoTuristico> >(MockBehavior.Strict);
            var    repoLogicaCat        = new Mock <ICategoria>(MockBehavior.Strict);
            PuntoTuristico_Logic logica = new PuntoTuristico_Logic(repoMock.Object, repoLogicaCat.Object);
            PuntoTuristico       punto  = logica.PuntoTuristico(nombre, descripcion);

            punto.Id = 1;

            Categoria categoria = new Categoria()
            {
                Id     = 0,
                Nombre = "Playa"
            };

            repoMock.Setup(x => x.Get(punto.Id)).Returns(punto);
            repoLogicaCat.Setup(x => x.ObtenerCategoriaId(categoria.Id)).Returns(categoria);
            repoMock.Setup(x => x.Update(punto));
            repoMock.Setup(x => x.Save());

            logica.AgregarPuntoCategoria(punto.Id, categoria.Id);

            Assert.AreEqual(1, punto.PuntosTuristicosCategoria.Count);
        }
Beispiel #3
0
        public void ObtenerPuntoIdNoExiste()
        {
            string nombre               = "Este";
            string descripcion          = "Prueba";
            var    repoMock             = new Mock <IRepository <PuntoTuristico> >(MockBehavior.Strict);
            var    repoLogicaCat        = new Mock <ICategoria>(MockBehavior.Strict);
            PuntoTuristico_Logic logica = new PuntoTuristico_Logic(repoMock.Object, repoLogicaCat.Object);
            PuntoTuristico       punto  = logica.PuntoTuristico(nombre, descripcion);

            punto.Id = 1;
            repoMock.Setup(x => x.Get(2)).Throws(new EntidadNoExisteExcepcion());
            Assert.Throws <EntidadNoExisteExcepcion>(() => logica.ObtenerPuntoId(2));
        }
Beispiel #4
0
        public void ObtenerPuntoIdValido()
        {
            string nombre               = "Este";
            string descripcion          = "Prueba";
            var    repoMock             = new Mock <IRepository <PuntoTuristico> >(MockBehavior.Strict);
            var    repoLogicaCat        = new Mock <ICategoria>(MockBehavior.Strict);
            PuntoTuristico_Logic logica = new PuntoTuristico_Logic(repoMock.Object, repoLogicaCat.Object);
            PuntoTuristico       punto  = logica.PuntoTuristico(nombre, descripcion);

            punto.Id = 1;
            repoMock.Setup(x => x.Get(1)).Returns(punto);
            PuntoTuristico resultado = logica.ObtenerPuntoId(1);

            Assert.AreEqual(nombre, resultado.Nombre);
        }
Beispiel #5
0
        public void TestCrearPuntoValido()
        {
            string         nombre      = "Punta del este";
            string         descripcion = "aaaaa";
            PuntoTuristico esperado    = new PuntoTuristico();

            esperado.Nombre      = nombre;
            esperado.Descripcion = descripcion;
            var repoMock                = new Mock <IRepository <PuntoTuristico> >(MockBehavior.Strict);
            var repoLogicaCat           = new Mock <ICategoria>(MockBehavior.Strict);
            PuntoTuristico_Logic logica = new PuntoTuristico_Logic(repoMock.Object, repoLogicaCat.Object);
            PuntoTuristico       punto  = logica.PuntoTuristico(nombre, descripcion);

            Assert.AreEqual(esperado.Nombre, punto.Nombre);
        }
Beispiel #6
0
        public void TestSubirImagenValido()
        {
            string nombre      = "Punta del este";
            string descripcion = "aaaaa";
            Imagen path        = new Imagen()
            {
                Id = 0, Ruta = "test"
            };
            var repoMock                = new Mock <IRepository <PuntoTuristico> >(MockBehavior.Strict);
            var repoLogicaCat           = new Mock <ICategoria>(MockBehavior.Strict);
            PuntoTuristico_Logic logica = new PuntoTuristico_Logic(repoMock.Object, repoLogicaCat.Object);
            PuntoTuristico       punto  = logica.PuntoTuristico(nombre, descripcion);

            logica.CargarImagen(punto, path);
            Assert.IsNotNull(punto.Imagen);
        }