public void Should_Fail_Get_All_Data()
        {
            var mockFacade = new Mock <IGarmentReceiptCorrectionReportFacade>();

            var mockMapper = new Mock <IMapper>();

            GarmentReceiptCorrectionReportController controller = GetController(mockFacade, null, mockMapper);
            var response = controller.GetReport(null, null, null, null, 0, 0, "");

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
        public void Should_Success_Get_Xls_Data()
        {
            var mockFacade = new Mock <IGarmentReceiptCorrectionReportFacade>();

            mockFacade.Setup(x => x.GenerateExcel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>(), It.IsAny <string>()))
            .Returns(new MemoryStream());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentReceiptCorrectionReportViewModel> >(It.IsAny <List <GarmentReceiptCorrection> >()))
            .Returns(new List <GarmentReceiptCorrectionReportViewModel> {
                ViewModel
            });

            GarmentReceiptCorrectionReportController controller = GetController(mockFacade, null, mockMapper);
            var response = controller.GetXls(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>());

            Assert.NotNull(response.GetType().GetProperty("FileDownloadName"));
        }
        private GarmentReceiptCorrectionReportController GetController(Mock <IGarmentReceiptCorrectionReportFacade> facadeMock, Mock <IValidateService> validateMock = null, Mock <IMapper> mapperMock = null)
        {
            var user   = new Mock <ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

            user.Setup(u => u.Claims).Returns(claims);

            var servicePMock = GetServiceProvider();

            if (validateMock != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IValidateService)))
                .Returns(validateMock.Object);
            }
            if (mapperMock != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IMapper)))
                .Returns(mapperMock.Object);
            }

            GarmentReceiptCorrectionReportController controller = new GarmentReceiptCorrectionReportController(servicePMock.Object, facadeMock.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = user.Object
                    }
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["Authorization"] = "Bearer unittesttoken";
            controller.ControllerContext.HttpContext.Request.Path = new PathString("/v1/unit-test");
            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "7";

            return(controller);
        }
        public void Should_Success_Get_All_Data()
        {
            var mockFacade = new Mock <IGarmentReceiptCorrectionReportFacade>();

            mockFacade.Setup(x => x.GetReport(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(Tuple.Create(new List <GarmentReceiptCorrectionReportViewModel> {
                ViewModel
            }, 25));

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentReceiptCorrectionReportViewModel> >(It.IsAny <List <GarmentReceiptCorrection> >()))
            .Returns(new List <GarmentReceiptCorrectionReportViewModel> {
                ViewModel
            });

            GarmentReceiptCorrectionReportController controller = GetController(mockFacade, null, mockMapper);
            var response = controller.GetReport(null, null, null, null, 0, 0, "");

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