public void Should_OK_Get_Report_Data() { var mockFacade = new Mock <IGarmentPurchaseRequestFacade>(); mockFacade.Setup(s => s.GetMonitoringPurchaseReport(null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1, 25, "{}", 7)) .ReturnsAsync(new List <MonitoringPurchaseAllUserViewModel>()); var user = new Mock <ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); GarmentMonitoringPurchaseController controller = new GarmentMonitoringPurchaseController(GetServiceProvider().Object, mockFacade.Object); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user.Object } }; controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "0"; //Act IActionResult response = controller.GetReport(null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1, 25, "{}"); //Assert Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }
public void Should_Error_Get_Report_Data() { var mockFacade = new Mock <IGarmentPurchaseRequestFacade>(); mockFacade.Setup(x => x.GetMonitoringPurchaseReport(null, null, null, null, null, null, null, null, null, null, null, null, 1, 25, "{}", 7)) .Returns(Tuple.Create(new List <MonitoringPurchaseAllUserViewModel> { ViewModel }, 25)); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(x => x.Map <List <MonitoringPurchaseAllUserViewModel> >(It.IsAny <List <GarmentPurchaseRequestViewModel> >())) .Returns(new List <MonitoringPurchaseAllUserViewModel> { ViewModel }); var user = new Mock <ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); GarmentMonitoringPurchaseController controller = new GarmentMonitoringPurchaseController(GetServiceProvider().Object, mockFacade.Object); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user.Object } }; controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "0"; var response = controller.GetReport(null, null, null, null, null, null, null, null, null, null, null, null, 1, 25, "{}"); Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response)); }