Пример #1
0
        public void Should_Sucess_Get_Excel()
        {
            var mockFacade = new Mock <IGarmentInternNoteFacade>();

            mockFacade.Setup(x => x.GenerateExcelIn(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>()))
            .Returns(new MemoryStream());
            var mockMapper    = new Mock <IMapper>();
            var IPOmockFacade = new Mock <IGarmentDeliveryOrderFacade>();
            var INVFacade     = new Mock <IGarmentInvoice>();
            var user          = new Mock <ClaimsPrincipal>();
            var claims        = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

            user.Setup(u => u.Claims).Returns(claims);
            GarmentInternNoteController controller = new GarmentInternNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object, IPOmockFacade.Object, INVFacade.Object);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user.Object
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "0";
            var response = controller.GetXlsDO2(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>());

            Assert.Equal("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", response.GetType().GetProperty("ContentType").GetValue(response, null));
        }
Пример #2
0
        public void Should_Error_Get_Excel()
        {
            var mockFacade    = new Mock <IGarmentInternNoteFacade>();
            var mockMapper    = new Mock <IMapper>();
            var IPOmockFacade = new Mock <IGarmentDeliveryOrderFacade>();
            var INVFacade     = new Mock <IGarmentInvoice>();

            GarmentInternNoteController controller = new GarmentInternNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object, IPOmockFacade.Object, INVFacade.Object);
            var response = controller.GetXlsDO2(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>());

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }