public async Task ListServicesID_Ocupada()
        {
            // Arrange
            using (context)
            {
                Habitacion hab = await context.Habitacion.SingleOrDefaultAsync <Habitacion>(m => m.numero == 1);

                ICollection <Servicio> listServices = await context.Servicio.ToListAsync();

                ListSolicitarServicioViewModel expectedModel = new ListSolicitarServicioViewModel {
                    numeroHab = hab.numero, ListaServicios = listServices, ocupada = hab.ocupada
                };

                var controller = new ServiciosController(context);
                // Act
                var result = await controller.ListServices(1);

                //Assert
                var viewResult = Assert.IsType <ViewResult>(result);
                ListSolicitarServicioViewModel model = (result as ViewResult).Model as ListSolicitarServicioViewModel;
                var expectedListServices             = model.ListaServicios.ToList();
                Assert.Equal(expectedModel, model, Comparer.Get <ListSolicitarServicioViewModel>((p1, p2) => p1.numeroHab == p2.numeroHab && p1.ocupada == p2.ocupada));
                Assert.Equal(expectedListServices, listServices, Comparer.Get <Servicio>((p1, p2) => p1.idServicio == p2.idServicio));
            }
        }
Example #2
0
        public async Task Verificar_PostServicio()
        {
            //ARRANGE
            Servicio nuevo = new Servicio {
                Id = 3, EnfermeroId = 3, OfertaId = 2, Estado = "activo", Costo = 100
            };
            ServicioCreateDTO nuevoCreate = new ServicioCreateDTO {
                EnfermeroId = 3, OfertaId = 2
            };
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper     = mockMapper.CreateMapper();
            var repository = new Mock <IServicioRepository>();

            repository.Setup(x => x.Save(It.IsAny <Servicio>())).ReturnsAsync(nuevo).Verifiable();
            var controller = new ServiciosController(repository.Object, mapper);

            //ACT
            var actionResult = await controller.Post(nuevoCreate);

            var result = actionResult.Result as CreatedAtRouteResult;
            var dto    = result.Value as ServicioDTO;

            //ASSERT
            Assert.Equal(3, dto.Id);
        }
        public async Task ListServices_NoOcupada()
        {
            // Arrange
            using (context)
            {
                var controller = new ServiciosController(context);
                // Act
                var result = await controller.ListServices(2);

                //Assert
                var viewResult = Assert.IsType <RedirectToActionResult>(result);
                Assert.Equal(viewResult.ControllerName, "Habitacions");
                Assert.Equal(viewResult.ActionName, "Index");
            }
        }
Example #4
0
        public async Task SelectService_ModelIsValid()
        {
            // Arrange
            using (context)
            {
                SelectedServiceViewModel selserViewModel = new SelectedServiceViewModel {
                    idServicio = 1, numeroHab = 1
                };
                var controller = new ServiciosController(context);
                // Act
                var result = await controller.SelectService(selserViewModel);

                //Assert
                var viewResult = Assert.IsType <RedirectToActionResult>(result);
                Assert.Equal(viewResult.ActionName, "SetReservaServicio");
            }
        }
        public async Task SetReservaServicio_ModelIsNotValid()
        {
            // Arrange
            using (context)
            {
                SelectedServiceViewModel selserViewModel = new SelectedServiceViewModel {
                    idServicio = 1
                };

                var controller = new ServiciosController(context);
                controller.ModelState.AddModelError("numeroHab", "requerido");
                // Act
                var result = await controller.SetReservaServicio(selserViewModel);

                //Assert
                var viewResult = Assert.IsType <RedirectToActionResult>(result);
                Assert.Equal(viewResult.ActionName, "ListServices");
            }
        }
        public async Task SetReservaServicio_ModelIsValid()
        {
            // Arrange
            using (context)
            {
                SelectedServiceViewModel selserViewModel = new SelectedServiceViewModel {
                    idServicio = 1, numeroHab = 1
                };
                SelectedServiceViewModel expectedModel = new SelectedServiceViewModel {
                    idServicio = 1, numeroHab = 1
                };
                var controller = new ServiciosController(context);
                // Act
                var result = await controller.SetReservaServicio(selserViewModel);

                //Assert
                var viewResult = Assert.IsType <ViewResult>(result);
                SelectedServiceViewModel model = (result as ViewResult).Model as SelectedServiceViewModel;
                Assert.Equal(expectedModel, model, Comparer.Get <SelectedServiceViewModel>((p1, p2) => p1.idServicio == p2.idServicio));
            }
        }
Example #7
0
        public async Task Verificar_GetServicio()
        {
            //ARRANGE
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper     = mockMapper.CreateMapper();
            var repository = new Mock <IServicioRepository>();

            repository.Setup(x => x.Get(It.IsAny <int>())).ReturnsAsync(servicio);
            var controller = new ServiciosController(repository.Object, mapper);

            //ACT
            var actionResult = await controller.Get(1);

            var result = actionResult.Result as OkObjectResult;
            var dto    = result.Value as ServicioDTO;

            //ASSERT
            Assert.NotNull(result);
            Assert.IsType <ServicioDTO>(dto);
            Assert.Equal(1, dto.Id);
        }
Example #8
0
        public async Task Verificar_GetListServicios()
        {
            //ARRANGE
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper     = mockMapper.CreateMapper();
            var repository = new Mock <IServicioRepository>();

            repository.Setup(x => x.GetAll()).ReturnsAsync(listaServicios);
            var controller = new ServiciosController(repository.Object, mapper);

            //ACT
            var actionResult = await controller.Get();

            var result = actionResult.Result as OkObjectResult;
            var arr    = result.Value as List <ServicioDTO>;

            //ASSERT
            Assert.NotNull(result);
            Assert.IsType <List <ServicioDTO> >(arr);
            Assert.Equal(2, arr.Count);
        }
Example #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["MOD"] == "REP_BANDOPORT")
        {
            Dictionary <string, string> dataJSON = JsonConvert.DeserializeObject <Dictionary <string, string> >(Request["valores"]);
            String FechaInicio = DateUtils.getStringDateYYMMDDHHMM(dataJSON["FechaInicio"].ToString());
            String FechaFin    = DateUtils.getStringDateYYMMDDHHMM(dataJSON["FechaFin"].ToString());
            String Codigo      = dataJSON["Codigo"].ToString();
            String Coordinador = dataJSON["Coordinador"].ToString();
            String Responsable = dataJSON["Responsable"].ToString();
            String Estado      = dataJSON["Estado"].ToString();
            String Etapa       = dataJSON["Etapa"].ToString();
            String Rubro       = dataJSON["Rubro"].ToString();
            String ConfRep     = dataJSON["ConfRep"].ToString();
            String Cliente     = dataJSON["Cliente"].ToString();
            var    usuSession  = Session["lgn_id"].ToString();

            //PAG
            var item = new OportunidadBean()
            {
                FechaInicio = FechaInicio,
                FechaFin    = FechaFin,
                Codigo      = Codigo,
                Responsable = Responsable,
                Estado      = Estado,
                Etapa       = Etapa,
                Rubro       = Rubro,
                ConfRep     = ConfRep,
                Cliente     = Cliente,
                UsuSession  = usuSession,
                Coordinador = Coordinador
            };

            //1:Administrador,2:Jefe de Ventas,3:Coordinador Go2Market,4:Supervisor Venta,5:Vendedor



            DataTable     dt      = OportunidadController.GetReporteAllPaginateOportunidadesExcel(item);
            List <String> colores = new List <String>();
            foreach (DataRow rowIV in dt.Rows)
            {
                if (rowIV["Retrazo"].ToString() == "T")
                {
                    colores.Add("#ff6666");
                }
                else
                {
                    colores.Add("");
                }
            }
            ExcelFileSpreadsheet exportExcel = this.prepararExportacionExcelReporteOportunidades(dt);
            ExcelFileUtils.ExportToExcelColor(exportExcel, colores, "ReporteOportunidad");
        }

        else if (Request["MOD"] == "REP_TRACKING")
        {
            Dictionary <string, string> dataJSON = JsonConvert.DeserializeObject <Dictionary <string, string> >(Request["valores"]);
            String Fecha       = dataJSON["Fecha"].ToString();
            String JefeVenta   = dataJSON["JefeVenta"].ToString();
            String Supervisor  = dataJSON["Supervisor"].ToString();
            String Grupo       = dataJSON["Grupo"].ToString();
            String coordinador = "";
            String Vendedor    = dataJSON["Vendedor"].ToString();
            String Tipo        = dataJSON["Tipo"].ToString();


            //PAG
            String pagina = "0";
            String filas  = "10";// dataJSON["filas"].ToString();

            var item = new ReporteBean();

            //1:Administrador,2:Jefe de Ventas,3:Coordinador Go2Market,4:Supervisor Venta,5:Vendedor
            var perfil = Session["lgn_perfil"].ToString();
            if (perfil == "3")
            {
                coordinador = Session["lgn_codigo"].ToString();
            }
            else if (perfil == "2")
            {
                JefeVenta = Session["lgn_codigo"].ToString();
            }
            else if (perfil == "4")
            {
                Supervisor = Session["lgn_codigo"].ToString();
            }
            DataTable dt = TrackingController.getReporteTrackingDataTable(DateUtils.getStringDateYYMMDDHHMM(Fecha), coordinador, JefeVenta, Supervisor, Grupo, Vendedor, Tipo);

            ExcelFileSpreadsheet exportExcel = this.prepararExportacionExcelReporteTracking(dt);
            ExcelFileUtils.ExportToExcel(exportExcel, "ReporteTracking");
        }
        else if (Request["MOD"] == "REP_SERVICIOS")
        {
            Int64 lsNextel = Int64.Parse(Request["Nextel"].ToString());
            Int64 lsGrupo  = Int64.Parse(Request["Grupo"].ToString());

            string[] lsFechaInicio = (Request["FechaInicio"].ToString()).Split('/');
            string[] lsHoraInicio  = (Request["HoraInicio"].ToString().Equals("24:00")) ? "23:59".Split(':') : Request["HoraInicio"].ToString().Split(':');
            string[] lsFechaFin    = (Request["FechaFin"].ToString()).Split('/');
            string[] lsHoraFin     = (Request["HoraFin"].ToString().Equals("24:00")) ? "23:59".Split(':') : Request["HoraFin"].ToString().Split(':');


            DateTime loDtInicio = new DateTime(Int32.Parse(lsFechaInicio[2]), Int32.Parse(lsFechaInicio[1]), Int32.Parse(lsFechaInicio[0]), Int32.Parse(lsHoraInicio[0]), Int32.Parse(lsHoraInicio[1]), 0);
            DateTime loDtFin    = new DateTime(Int32.Parse(lsFechaFin[2]), Int32.Parse(lsFechaFin[1]), Int32.Parse(lsFechaFin[0]), Int32.Parse(lsHoraFin[0]), Int32.Parse(lsHoraFin[1]), 0);

            Int64 lsIdSupervisor = 0;
            if (Session["lgn_id"] != null)
            {
                lsIdSupervisor = Int64.Parse(Session["lgn_id"].ToString());
            }

            String lsFlagGps     = Request["FlagGps"].ToString();
            String lsFlagNetwork = Request["FlagNetwork"].ToString();
            String lsFlagDatos   = Request["FlagDatos"].ToString();
            String lsFlagWifi    = Request["FlagWifi"].ToString();


            DataTable            ldtServicios = ServiciosController.subReporteServiciosXLS(lsNextel, lsGrupo, loDtInicio, loDtFin, lsIdSupervisor, lsFlagGps, lsFlagNetwork, lsFlagDatos, lsFlagWifi);
            ExcelFileSpreadsheet exportExcel  = this.prepararExportacionExcelServicios(ldtServicios, String.Join("/", lsFechaInicio), String.Join("/", lsFechaFin));
            ExcelFileUtils.ExportToExcel(exportExcel, Model.bean.IdiomaCultura.getMensaje(Model.bean.IdiomaCultura.ETI_SUP_PLU));
        }
    }
        public void DetailsTest()
        {
            var controller = new ServiciosController();

            Assert.Fail();
        }
        public void IndexTest()
        {
            var controller = new ServiciosController();

            Assert.Fail();
        }