public async Task GenerateExcel_WithoutException_ReturnOK() { var dbContext = DbContext(GetCurrentMethod()); var serviceProvider = GetServiceProviderMock(dbContext).Object; FinishingPrintingSalesContractReportFacade facade = new FinishingPrintingSalesContractReportFacade(serviceProvider, dbContext); FinishingPrintingSalesContractFacade fpFacade = new FinishingPrintingSalesContractFacade(serviceProvider, dbContext); var controller = GetController(facade); var data = await DataUtil(fpFacade, dbContext).GetTestData(); var response = controller.GetXlsAll(null, null, null, null, DateTime.MinValue, DateTime.MaxValue); Assert.NotNull(response); }
public async Task GetReportAll_WithoutException_ReturnOK() { var dbContext = DbContext(GetCurrentMethod()); var serviceProvider = GetServiceProviderMock(dbContext).Object; FinishingPrintingSalesContractReportFacade facade = new FinishingPrintingSalesContractReportFacade(serviceProvider, dbContext); FinishingPrintingSalesContractFacade fpFacade = new FinishingPrintingSalesContractFacade(serviceProvider, dbContext); var controller = GetController(facade); var data = await DataUtil(fpFacade, dbContext).GetTestData(); var response = controller.GetReportAll(null, null, null, null, DateTime.MinValue, DateTime.MaxValue, 1, 25); int statusCode = this.GetStatusCode(response); Assert.Equal((int)HttpStatusCode.OK, statusCode); }
protected FinishingPrintingSalesContractReportController GetController(FinishingPrintingSalesContractReportFacade facade) { var user = new Mock <ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); FinishingPrintingSalesContractReportController controller = (FinishingPrintingSalesContractReportController)Activator.CreateInstance(typeof(FinishingPrintingSalesContractReportController), facade); 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"); return(controller); }
//private readonly IdentityService identityService; public FinishingPrintingSalesContractReportController(FinishingPrintingSalesContractReportFacade facade)//, IdentityService identityService) { _facade = facade; //this.identityService = identityService; }