public void Should_Success_Get_All_Data() { var mockFacade = new Mock <IGarmentFlowDetailMaterialReport>(); mockFacade.Setup(x => x.GetReport(It.IsAny <string>(), It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())) .Returns(Tuple.Create(new List <GarmentFlowDetailMaterialViewModel> { ViewModel }, 25)); var mockMapper = new Mock <IMapper>(); var user = new Mock <ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); GarmentFlowDetailMaterialController controller = GetController(mockFacade, null, mockMapper); 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, 0, 0, ""); Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }
public void Should_Fail_Get_All_Data() { var mockFacade = new Mock <IGarmentFlowDetailMaterialReport>(); var mockMapper = new Mock <IMapper>(); GarmentFlowDetailMaterialController controller = GetController(mockFacade, null, null); var response = controller.GetReport(null, null, null, 0, 0, ""); Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response)); }