示例#1
0
        public void Should_Error_Get_Report_Data()
        {
            var mockFacade = new Mock <IDebtCardReportFacade>();
            //mockFacade.Setup(x => x.GetDebtCardReport(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()))
            //    .Returns(Tuple.Create(new List<GarmentDebtCardReportViewModel> { viewModel }, 25));

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentDebtCardReportViewModel> >(It.IsAny <List <GarmentDebtCardReportViewModel> >()))
            .Returns(new List <GarmentDebtCardReportViewModel> {
                viewModel
            });

            var user   = new Mock <ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

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

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user.Object
                }
            };
            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "0";
            var response = controller.GetReport(0, 0, null, null, null, null);

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
示例#2
0
        public void Should_Success_Get_Report()
        {
            var mockFacade = new Mock <IDebtCardReportFacade>();

            mockFacade.Setup(x => x.GetDebtCardReport(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()))
            .Returns(Tuple.Create(new List <GarmentDebtCardReportViewModel> {
                viewModel
            }, 25));

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentDebtCardReportViewModel> >(It.IsAny <List <GarmentDebtCardReportViewModel> >()))
            .Returns(new List <GarmentDebtCardReportViewModel> {
                viewModel
            });

            var user   = new Mock <ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

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

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

            var response = controller.GetReport(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>());

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