public void Should_Error_Get_Xls_Flow_Product() { var mockFacade = new Mock <IMonitoringFlowProductFacade>(); mockFacade.Setup(x => x.GetProductFlowExcel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(new MemoryStream()); var user = new Mock <ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); MonitoringFlowProductController controller = new MonitoringFlowProductController(mockFacade.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.GetInExcel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()); Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response)); }
public void Should_Success_Get_Xls_Flow_Product() { var mockFacade = new Mock <IMonitoringFlowProductFacade>(); mockFacade.Setup(x => x.GetProductFlowExcel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(new MemoryStream()); var user = new Mock <ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); MonitoringFlowProductController controller = new MonitoringFlowProductController(mockFacade.Object, GetServiceProvider().Object); controller.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"; controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "0"; var response = controller.GetInExcel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()); Assert.Equal("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", response.GetType().GetProperty("ContentType").GetValue(response, null)); }