Beispiel #1
0
        public void ListadoExpedienteConPedimentoInexistenteRegresaError()
        {
            //Arrange
            //ClaimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity().)

            Moq.Mock <IIdentityExtensions> mockI = new Moq.Mock <IIdentityExtensions>();
            mockI.Setup(s => s.GetClientId(It.IsAny <IIdentity>())).Returns("590");
            mockI.Setup(s => s.GetNombreCliente(It.IsAny <IIdentity>())).Returns("DANFOSS INDUSTRIES S. DE R. L.");

            IdentityExtensions.Implementation = mockI.Object;

            Moq.Mock <ClaimsPrincipal> mockP = new Moq.Mock <ClaimsPrincipal>();
            mockP.SetupGet(p => p.Identity.Name).Returns("*****@*****.**");
            mockP.Setup(p => p.IsInRole("Administrador")).Returns(false);
            mockP.Setup(p => p.FindFirst("ClientId")).Returns(new Claim("ClientId", "590"));
            mockP.As <IPrincipal>();
            IPrincipal unmockedIPrincipal = mockP.Object;

            //((ClaimsIdentity)unmockedIPrincipal.Identity).AddClaim(new Claim("ClientId", "590"));

            Moq.Mock <ControllerContext> mockContext = new Moq.Mock <ControllerContext>();
            mockContext.SetupGet(p => p.HttpContext.User).Returns(unmockedIPrincipal);
            mockContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);

            var controller = new InternetReports.Areas.Operacion.Controllers.DescargaExpedientesController();

            controller.ControllerContext = mockContext.Object;
            controller._catalogos        = new InternetReports.Models.FakeARCHIVOS_ALT();
            var pedimento = new InternetReports.Models.PedimentosSaaiSirView()
            {
                Referencia = "1900024-00",
                Pedimento  = "9000751",
                Aduana     = "81",
                Seccion    = "0",
                IdClienteC = 590,
                IdClienteP = 590,
                FechaPago  = new DateTime(2019, 1, 10)
            };

            controller._catalogos.PedimentosSaaiSirViews.Add(pedimento);
            controller._catalogos.SaveChanges();

            BusquedaExpedienteViewModel busquedaViewModel = new BusquedaExpedienteViewModel()
            {
                Pedimento = "9000754",
                Aduana    = "810",
                Año       = "2019"
            };

            //Act
            ViewResult result = controller.ListadoExpediente(busquedaViewModel).Result as ViewResult;

            //Assert
            Assert.AreEqual("Index", result.ViewName);
            Assert.IsTrue(result.ViewData.ModelState.ContainsKey("PedimentoNoEncontrado"));
            Assert.IsNotNull(result.ViewData.ModelState["PedimentoNoEncontrado"].Errors);
            Assert.IsNotNull(result.ViewData.ModelState["PedimentoNoEncontrado"].Errors.Contains(new ModelError("No se encontró el pedimento o la referencia requerida")));
        }
Beispiel #2
0
        public void Index()
        {
            //Arrange
            var controller = new InternetReports.Areas.Operacion.Controllers.DescargaExpedientesController();

            //Act
            ActionResult result = controller.Index();

            //Assert
        }