public void Json_SerializeModel_Fail() { var ser = new JsonSerializationService(); var recurse = new RecurseModel(); recurse.ToInfinity = recurse; var result = ser.Serialize(recurse); Assert.IsNotNull(result); }
public void Json_SerializeModel_Succeed() { var now = DateTime.Now; var model = ReminderFactory.Create(now); Assert.AreEqual(now, model.NextDue); var ser = new JsonSerializationService(); var result = ser.Serialize(model); Assert.IsNotNull(result); }
public async Task TestHNSReportGeneration(string ilrFilename, string fm25Filename) { string csv = string.Empty; DateTime dateTime = DateTime.UtcNow; string filename = $"10033670_1_High Needs Students Detail Report {dateTime:yyyyMMdd-HHmmss}"; Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10033670); reportServiceContextMock.SetupGet(x => x.Filename).Returns(ilrFilename); reportServiceContextMock.SetupGet(x => x.FundingFM25OutputKey).Returns("FundingFm25Output"); reportServiceContextMock.SetupGet(x => x.ValidLearnRefNumbersKey).Returns("ValidLearnRefNumbers"); reportServiceContextMock.SetupGet(x => x.CollectionName).Returns("ILR1819"); DataStoreConfiguration dataStoreConfiguration = new DataStoreConfiguration() { ILRDataStoreConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreConnectionString, ILRDataStoreValidConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreValidConnectionString }; IIlr1819ValidContext IlrValidContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntitiesValid>().UseSqlServer(dataStoreConfiguration.ILRDataStoreValidConnectionString).Options; return(new ILR1819_DataStoreEntitiesValid(options)); } IIlr1819RulebaseContext IlrRulebaseContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntities>().UseSqlServer(dataStoreConfiguration.ILRDataStoreConnectionString).Options; return(new ILR1819_DataStoreEntities(options)); } Mock <ILogger> logger = new Mock <ILogger>(); Mock <IDateTimeProvider> dateTimeProviderMock = new Mock <IDateTimeProvider>(); Mock <IStreamableKeyValuePersistenceService> storage = new Mock <IStreamableKeyValuePersistenceService>(); Mock <IStreamableKeyValuePersistenceService> redis = new Mock <IStreamableKeyValuePersistenceService>(); IIntUtilitiesService intUtilitiesService = new IntUtilitiesService(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); IXmlSerializationService xmlSerializationService = new XmlSerializationService(); IFM25ProviderService fm25ProviderService = new FM25ProviderService(logger.Object, storage.Object, jsonSerializationService, IlrRulebaseContextFactory); IIlrProviderService ilrProviderService = new IlrFileServiceProvider(logger.Object, storage.Object, xmlSerializationService); IValidLearnersService validLearnersService = new ValidLearnersService(logger.Object, redis.Object, jsonSerializationService, dataStoreConfiguration); IValueProvider valueProvider = new ValueProvider(); IHNSReportModelBuilder reportModelBuilder = new HNSReportModelBuilder(); storage.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <Stream>(), It.IsAny <CancellationToken>())) .Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead(ilrFilename).CopyTo(sr)) .Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.csv", It.IsAny <string>(), It.IsAny <CancellationToken>())) .Callback <string, string, CancellationToken>((key, value, ct) => csv = value) .Returns(Task.CompletedTask); storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.GetAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(jsonSerializationService.Serialize( new List <string> { "0Addl103", "0ContPr01", "1ContPr01", "2ContPr01" })); storage.Setup(x => x.ContainsAsync("FundingFm25Output", It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.GetAsync("FundingFm25Output", It.IsAny <CancellationToken>())) .ReturnsAsync(File.ReadAllText(fm25Filename)); storage.Setup(x => x.ContainsAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(dateTime); dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(It.IsAny <DateTime>())).Returns(dateTime); var hnsReport = new HNSDetailReport( logger.Object, storage.Object, ilrProviderService, validLearnersService, fm25ProviderService, dateTimeProviderMock.Object, valueProvider, reportModelBuilder); await hnsReport.GenerateReport(reportServiceContextMock.Object, null, false, CancellationToken.None); csv.Should().NotBeNullOrEmpty(); #if DEBUG File.WriteAllText($"{filename}.csv", csv); #endif TestCsvHelper.CheckCsv(csv, new CsvEntry(new HNSMapper(), 1)); }
public async Task TestAllbOccupancyReportGeneration() { string csv = string.Empty; System.DateTime dateTime = System.DateTime.UtcNow; string filename = $"10033670_1_ALLB Occupancy Report {dateTime:yyyyMMdd-HHmmss}"; Mock <ILogger> logger = new Mock <ILogger>(); Mock <IStreamableKeyValuePersistenceService> storage = new Mock <IStreamableKeyValuePersistenceService>(); Mock <IStreamableKeyValuePersistenceService> redis = new Mock <IStreamableKeyValuePersistenceService>(); Mock <IDateTimeProvider> dateTimeProviderMock = new Mock <IDateTimeProvider>(); IXmlSerializationService xmlSerializationService = new XmlSerializationService(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); IIntUtilitiesService intUtilitiesService = new IntUtilitiesService(); storage.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <Stream>(), It.IsAny <CancellationToken>())) .Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead("ILR-10033670-1819-20180704-120055-03.xml").CopyTo(sr)).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.csv", It.IsAny <string>(), It.IsAny <CancellationToken>())) .Callback <string, string, CancellationToken>((key, value, ct) => csv = value).Returns(Task.CompletedTask); storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.GetAsync("FundingALBOutputKey", It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead("ALBOutput1000.json").CopyTo(sr)).Returns(Task.CompletedTask); redis.Setup(x => x.GetAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(jsonSerializationService.Serialize( new List <string> { "3Addl103", "4Addl103" })); dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(dateTime); dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(It.IsAny <DateTime>())).Returns(dateTime); DataStoreConfiguration dataStoreConfiguration = new DataStoreConfiguration() { ILRDataStoreConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreConnectionString, ILRDataStoreValidConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreValidConnectionString }; IIlr1819ValidContext IlrValidContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntitiesValid>().UseSqlServer(dataStoreConfiguration.ILRDataStoreValidConnectionString).Options; return(new ILR1819_DataStoreEntitiesValid(options)); } IIlr1819RulebaseContext IlrRulebaseContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntities>().UseSqlServer(dataStoreConfiguration.ILRDataStoreConnectionString).Options; return(new ILR1819_DataStoreEntities(options)); } IIlrProviderService ilrProviderService = new IlrProviderService(logger.Object, storage.Object, xmlSerializationService, dateTimeProviderMock.Object, intUtilitiesService, IlrValidContextFactory, IlrRulebaseContextFactory); Mock <ILarsProviderService> larsProviderService = new Mock <ILarsProviderService>(); larsProviderService.Setup(x => x.GetLearningDeliveriesAsync(It.IsAny <string[]>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new Dictionary <string, LarsLearningDelivery>() { { "60133533", new LarsLearningDelivery { LearningAimTitle = "A", NotionalNvqLevel = "B", Tier2SectorSubjectArea = 3 } } }); IAllbProviderService allbProviderService = new AllbProviderService(logger.Object, redis.Object, jsonSerializationService, intUtilitiesService, IlrValidContextFactory, IlrRulebaseContextFactory); Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10033670); reportServiceContextMock.SetupGet(x => x.Filename).Returns("ILR-10033670-1819-20180704-120055-03"); reportServiceContextMock.SetupGet(x => x.FundingALBOutputKey).Returns("FundingAlbOutput"); reportServiceContextMock.SetupGet(x => x.ValidLearnRefNumbersKey).Returns("ValidLearnRefNumbers"); IValidLearnersService validLearnersService = new ValidLearnersService(logger.Object, redis.Object, jsonSerializationService, null); IStringUtilitiesService stringUtilitiesService = new StringUtilitiesService(); ITopicAndTaskSectionOptions topicsAndTasks = TestConfigurationHelper.GetTopicsAndTasks(); IValueProvider valueProvider = new ValueProvider(); IReport allbOccupancyReport = new AllbOccupancyReport( logger.Object, storage.Object, ilrProviderService, larsProviderService.Object, allbProviderService, validLearnersService, stringUtilitiesService, dateTimeProviderMock.Object, valueProvider, topicsAndTasks); await allbOccupancyReport.GenerateReport(reportServiceContextMock.Object, null, false, CancellationToken.None); csv.Should().NotBeNullOrEmpty(); TestCsvHelper.CheckCsv(csv, new CsvEntry(new AllbOccupancyMapper(), 1)); }
public async Task TestSummaryOfFunding1619ReportGeneration() { string csv = string.Empty; System.DateTime dateTime = System.DateTime.UtcNow; string filename = $"10033670_1_16-19 Summary of Funding by Student Report {dateTime:yyyyMMdd-HHmmss}"; Mock <ILogger> logger = new Mock <ILogger>(); Mock <IDateTimeProvider> dateTimeProviderMock = new Mock <IDateTimeProvider>(); Mock <IStreamableKeyValuePersistenceService> storage = new Mock <IStreamableKeyValuePersistenceService>(); Mock <IKeyValuePersistenceService> redis = new Mock <IKeyValuePersistenceService>(); IIntUtilitiesService intUtilitiesService = new IntUtilitiesService(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); IXmlSerializationService xmlSerializationService = new XmlSerializationService(); DataStoreConfiguration dataStoreConfiguration = new DataStoreConfiguration() { ILRDataStoreConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreConnectionString, ILRDataStoreValidConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreValidConnectionString }; IIlr1819ValidContext IlrValidContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntitiesValid>().UseSqlServer(dataStoreConfiguration.ILRDataStoreValidConnectionString).Options; return(new ILR1819_DataStoreEntitiesValid(options)); } IIlr1819RulebaseContext IlrRulebaseContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntities>().UseSqlServer(dataStoreConfiguration.ILRDataStoreConnectionString).Options; return(new ILR1819_DataStoreEntities(options)); } IIlrProviderService ilrProviderService = new IlrProviderService(logger.Object, storage.Object, xmlSerializationService, dateTimeProviderMock.Object, intUtilitiesService, IlrValidContextFactory, IlrRulebaseContextFactory); Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10033670); reportServiceContextMock.SetupGet(x => x.Filename).Returns("ILR-10033670-1819-20180712-144437-03"); reportServiceContextMock.SetupGet(x => x.ValidLearnRefNumbersKey).Returns("ValidLearnRefNumbers"); reportServiceContextMock.SetupGet(x => x.FundingFM25OutputKey).Returns("FundingFm25Output"); IValidLearnersService validLearnersService = new ValidLearnersService(logger.Object, redis.Object, jsonSerializationService, null); IFM25ProviderService fm25ProviderService = new FM25ProviderService(logger.Object, storage.Object, jsonSerializationService, intUtilitiesService, IlrRulebaseContextFactory); IStringUtilitiesService stringUtilitiesService = new StringUtilitiesService(); IValueProvider valueProvider = new ValueProvider(); storage.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead("ILR-10033670-1819-20180712-144437-03.xml").CopyTo(sr)).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.csv", It.IsAny <string>(), It.IsAny <CancellationToken>())).Callback <string, string, CancellationToken>((key, value, ct) => csv = value).Returns(Task.CompletedTask); storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.GetAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(jsonSerializationService.Serialize( new List <string> { "0fm2501", "3fm9901", "5fm9901" })); redis.Setup(x => x.GetAsync("FundingFm25Output", It.IsAny <CancellationToken>())).ReturnsAsync(File.ReadAllText("Fm25.json")); redis.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(dateTime); dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(It.IsAny <System.DateTime>())).Returns(dateTime); ITopicAndTaskSectionOptions topicsAndTasks = TestConfigurationHelper.GetTopicsAndTasks(); SummaryOfFunding1619Report summaryOfFunding1619Report = new SummaryOfFunding1619Report( logger.Object, storage.Object, ilrProviderService, validLearnersService, fm25ProviderService, stringUtilitiesService, dateTimeProviderMock.Object, valueProvider, topicsAndTasks); await summaryOfFunding1619Report.GenerateReport(reportServiceContextMock.Object, null, false, CancellationToken.None); csv.Should().NotBeNullOrEmpty(); TestCsvHelper.CheckCsv(csv, new CsvEntry(new SummaryOfFunding1619Mapper(), 1)); }
public void GetAvailableCollections_Success() { var httpClientMock = new Mock <IBespokeHttpClient>(); var serialisationService = new JsonSerializationService(); var items = new List <Collection>() { new Collection() { CollectionTitle = "ILR1819", CollectionType = "ILR", IsOpen = true }, new Collection() { CollectionTitle = "ILR1718", CollectionType = "ILR", IsOpen = true }, }; httpClientMock.Setup(x => x.GetDataAsync("testurl/api/collections/10000/ILR")).ReturnsAsync(() => serialisationService.Serialize(items)); var pollyRegistryMock = new Mock <IReadOnlyPolicyRegistry <string> >(); pollyRegistryMock.Setup(x => x.Get <IAsyncPolicy>("HttpRetryPolicy")).Returns(Policy.NoOpAsync); var apiSettings = new ApiSettings() { JobManagementApiBaseUrl = "testurl/api" }; var service = new CollectionManagementService(httpClientMock.Object, apiSettings, new JsonSerializationService()); var data = service.GetAvailableCollectionsAsync(10000, "ILR").Result; data.Count().Should().Be(2); data.Any(x => x.CollectionName == "ILR1819" && x.IsOpen == true).Should().BeTrue(); data.Any(x => x.CollectionName == "ILR1718" && x.IsOpen == true).Should().BeTrue(); }
public void GetSubmissionOptions_Success() { var httpClientMock = new Mock <IBespokeHttpClient>(); var serialisationService = new JsonSerializationService(); var items = new List <CollectionType>() { new CollectionType() { Type = "ILR", Description = "ILR data submission" }, new CollectionType() { Type = "ESF", Description = "ESF data submission" } }; httpClientMock.Setup(x => x.GetDataAsync("testurl/api/org/collection-types/10000")).ReturnsAsync(() => serialisationService.Serialize(items)); var pollyRegistryMock = new Mock <IReadOnlyPolicyRegistry <string> >(); pollyRegistryMock.Setup(x => x.Get <IAsyncPolicy>("HttpRetryPolicy")).Returns(Policy.NoOpAsync); var apiSettings = new ApiSettings() { JobManagementApiBaseUrl = "testurl/api" }; var service = new CollectionManagementService(httpClientMock.Object, apiSettings, new JsonSerializationService()); var data = service.GetSubmssionOptionsAsync(10000).Result; data.Count().Should().Be(2); data.Any(x => x.Name == "ILR" && x.Title == "ILR data submission").Should().BeTrue(); data.Any(x => x.Name == "ESF" && x.Title == "ESF data submission").Should().BeTrue(); }
public void GetCurrentPeriod_Success() { var httpClientMock = new Mock <IBespokeHttpClient>(); var serialisationService = new JsonSerializationService(); var rp = new ReturnPeriod() { CollectionName = "ILR1819", PeriodNumber = 1, CalendarMonth = 8, CalendarYear = 2018, StartDateTimeUtc = new DateTime(2018, 8, 22), EndDateTimeUtc = new DateTime(2018, 9, 04) }; httpClientMock.Setup(x => x.GetDataAsync("testurl/api/returns-calendar/ILR1819/current")).ReturnsAsync(() => serialisationService.Serialize(rp)); var pollyRegistryMock = new Mock <IReadOnlyPolicyRegistry <string> >(); pollyRegistryMock.Setup(x => x.Get <IAsyncPolicy>("HttpRetryPolicy")).Returns(Policy.NoOpAsync); var apiSettings = new ApiSettings() { JobManagementApiBaseUrl = "testurl/api" }; var service = new CollectionManagementService(httpClientMock.Object, apiSettings, new JsonSerializationService()); var data = service.GetCurrentPeriodAsync("ILR1819").Result; data.Should().NotBeNull(); data.PeriodNumber.Should().Be(1); }
public async Task TestAppsIndicativeEarningsReportGeneration(string ilrFile, string fm36Output) { string csv = string.Empty; DateTime dateTime = DateTime.UtcNow; string filename = $"10033670_1_Apps Indicative Earnings Report {dateTime:yyyyMMdd-HHmmss}"; string ilr = ilrFile; DataStoreConfiguration dataStoreConfiguration = new DataStoreConfiguration() { ILRDataStoreConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreConnectionString, ILRDataStoreValidConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreValidConnectionString }; Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10033670); reportServiceContextMock.SetupGet(x => x.Filename).Returns(ilr); reportServiceContextMock.SetupGet(x => x.FundingFM36OutputKey).Returns("FundingFm36Output"); reportServiceContextMock.SetupGet(x => x.ValidLearnRefNumbersKey).Returns("ValidLearnRefNumbers"); reportServiceContextMock.SetupGet(x => x.CollectionName).Returns("ILR1819"); Mock <ILogger> logger = new Mock <ILogger>(); Mock <IDateTimeProvider> dateTimeProviderMock = new Mock <IDateTimeProvider>(); Mock <IStreamableKeyValuePersistenceService> storage = new Mock <IStreamableKeyValuePersistenceService>(); IIntUtilitiesService intUtilitiesService = new IntUtilitiesService(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); IXmlSerializationService xmlSerializationService = new XmlSerializationService(); IIlr1819ValidContext IlrValidContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntitiesValid>().UseSqlServer(dataStoreConfiguration.ILRDataStoreValidConnectionString).Options; return(new ILR1819_DataStoreEntitiesValid(options)); } IIlr1819RulebaseContext IlrRulebaseContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntities>().UseSqlServer(dataStoreConfiguration.ILRDataStoreConnectionString).Options; return(new ILR1819_DataStoreEntities(options)); } IIlrProviderService ilrProviderService = new IlrFileServiceProvider(logger.Object, storage.Object, xmlSerializationService); Mock <ILarsProviderService> larsProviderService = new Mock <ILarsProviderService>(); IValidLearnersService validLearnersService = new ValidLearnersService(logger.Object, storage.Object, jsonSerializationService, dataStoreConfiguration); IFM36ProviderService fm36ProviderService = new FM36FileServiceProvider(logger.Object, storage.Object, jsonSerializationService); IStringUtilitiesService stringUtilitiesService = new StringUtilitiesService(); ITotalBuilder totalBuilder = new TotalBuilder(); List <IAppsIndicativeCommand> commands = new List <IAppsIndicativeCommand>() { new AppsIndicativeAugustCommand() }; AppsIndicativeEarningsModelBuilder builder = new AppsIndicativeEarningsModelBuilder(commands, totalBuilder, stringUtilitiesService); storage.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead($"{ilr}.xml").CopyTo(sr)).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.csv", It.IsAny <string>(), It.IsAny <CancellationToken>())).Callback <string, string, CancellationToken>((key, value, ct) => csv = value).Returns(Task.CompletedTask); storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); storage.Setup(x => x.GetAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(jsonSerializationService.Serialize( new List <string> { "3DOB01", "0fm3501", "1fm3501", "2fm3501", "3fm3501", "4fm3501", "5fm3501", "6fm3501", "7fm3501", "8fm3501", "9fm3501", "Afm3501", "Bfm3501", "Cfm3501", "Dfm3501", "Efm3501", "0fm3601", "0DOB52", "fm36 18 20" })); storage.Setup(x => x.ContainsAsync("ValidLearners", It.IsAny <CancellationToken>())).ReturnsAsync(true); storage.Setup(x => x.ContainsAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(true); storage.Setup(x => x.ContainsAsync("FundingFm36Output", It.IsAny <CancellationToken>())).ReturnsAsync(true); storage.Setup(x => x.GetAsync("FundingFm36Output", It.IsAny <CancellationToken>())).ReturnsAsync(File.ReadAllText(fm36Output)); dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(dateTime); dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(It.IsAny <DateTime>())).Returns(dateTime); IMessage message = await ilrProviderService.GetIlrFile(reportServiceContextMock.Object, CancellationToken.None); string validLearners = await storage.Object.GetAsync("ValidLearnRefNumbers"); Dictionary <string, LarsLearningDelivery> learningDeliveriesDict = new Dictionary <string, LarsLearningDelivery>(); foreach (ILearner messageLearner in message.Learners) { if (!validLearners.Contains(messageLearner.LearnRefNumber)) { continue; } foreach (ILearningDelivery learningDelivery in messageLearner.LearningDeliveries) { learningDeliveriesDict[learningDelivery.LearnAimRef] = new LarsLearningDelivery() { LearningAimTitle = "A", NotionalNvqLevel = "B", Tier2SectorSubjectArea = 3 }; } } larsProviderService.Setup(x => x.GetLearningDeliveriesAsync(It.IsAny <string[]>(), It.IsAny <CancellationToken>())).ReturnsAsync(learningDeliveriesDict); larsProviderService.Setup(x => x.GetStandardAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync("NotionalEndLevel"); IValueProvider valueProvider = new ValueProvider(); var report = new AppsIndicativeEarningsReport( logger.Object, storage.Object, ilrProviderService, validLearnersService, fm36ProviderService, larsProviderService.Object, builder, dateTimeProviderMock.Object, valueProvider); await report.GenerateReport(reportServiceContextMock.Object, null, false, CancellationToken.None); csv.Should().NotBeNullOrEmpty(); File.WriteAllText($"{filename}.csv", csv); TestCsvHelper.CheckCsv(csv, new CsvEntry(new AppsIndicativeEarningsMapper(), 1)); }
public async Task TestMainOccupancyReportGeneration(string ilrFilename, string fm35Filename, string validLearner) { string csv = string.Empty; DateTime dateTime = DateTime.UtcNow; string filename = $"10033670_1_Main Occupancy Report {dateTime:yyyyMMdd-HHmmss}"; List <string> validLearners = new List <string> { validLearner }; Mock <ILogger> logger = new Mock <ILogger>(); Mock <IDateTimeProvider> dateTimeProviderMock = new Mock <IDateTimeProvider>(); Mock <IStreamableKeyValuePersistenceService> storage = new Mock <IStreamableKeyValuePersistenceService>(); Mock <IKeyValuePersistenceService> redis = new Mock <IKeyValuePersistenceService>(); Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); IIntUtilitiesService intUtilitiesService = new IntUtilitiesService(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); IXmlSerializationService xmlSerializationService = new XmlSerializationService(); IFM35ProviderService fm35ProviderService = new FM35ProviderService(logger.Object, storage.Object, jsonSerializationService, intUtilitiesService, null, null); IFM25ProviderService fm25ProviderService = new FM25ProviderService(logger.Object, storage.Object, jsonSerializationService, intUtilitiesService, null); IIlrProviderService ilrProviderService = new IlrProviderService(logger.Object, storage.Object, xmlSerializationService, dateTimeProviderMock.Object, intUtilitiesService, null, null); LarsConfiguration larsConfiguration = new LarsConfiguration { LarsConnectionString = ConfigurationManager.AppSettings["LarsConnectionString"] }; ILarsProviderService larsProviderService = new LarsProviderService(logger.Object, larsConfiguration); IStringUtilitiesService stringUtilitiesService = new StringUtilitiesService(); ITopicAndTaskSectionOptions topicsAndTasks = TestConfigurationHelper.GetTopicsAndTasks(); IMainOccupancyReportModelBuilder reportModelBuilder = new MainOccupancyReportModelBuilder(); IValueProvider valueProvider = new ValueProvider(); storage.Setup(x => x.GetAsync(ilrFilename, It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead(ilrFilename).CopyTo(sr)).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.csv", It.IsAny <string>(), It.IsAny <CancellationToken>())).Callback <string, string, CancellationToken>((key, value, ct) => csv = value).Returns(Task.CompletedTask); storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); storage.Setup(x => x.GetAsync("FundingFm35Output", It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead(fm35Filename).CopyTo(sr)).Returns(Task.CompletedTask); redis.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.GetAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(jsonSerializationService.Serialize(validLearners)); dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(dateTime); dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(It.IsAny <DateTime>())).Returns(dateTime); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10033670); reportServiceContextMock.SetupGet(x => x.Filename).Returns(ilrFilename); reportServiceContextMock.SetupGet(x => x.ValidLearnRefNumbersKey).Returns("ValidLearnRefNumbers"); reportServiceContextMock.SetupGet(x => x.FundingFM35OutputKey).Returns("FundingFm35Output"); reportServiceContextMock.SetupGet(x => x.CollectionName).Returns("ILR1819"); IValidLearnersService validLearnersService = new ValidLearnersService(logger.Object, redis.Object, jsonSerializationService, null); var mainOccupancyReport = new MainOccupancyReport( logger.Object, storage.Object, ilrProviderService, stringUtilitiesService, validLearnersService, fm25ProviderService, fm35ProviderService, larsProviderService, dateTimeProviderMock.Object, valueProvider, topicsAndTasks, reportModelBuilder); await mainOccupancyReport.GenerateReport(reportServiceContextMock.Object, null, false, CancellationToken.None); csv.Should().NotBeNullOrEmpty(); File.WriteAllText($"{filename}.csv", csv); }
public async Task TestFundingClaim1619ReportGeneration() { byte[] xlsx = null; string filename = $"10033670_1_16-19 Funding Claim Report {DateTime.UtcNow:yyyyMMdd-HHmmss}"; string csv = string.Empty; var dateTime = System.DateTime.UtcNow; Mock <ILogger> logger = new Mock <ILogger>(); Mock <IStreamableKeyValuePersistenceService> storage = new Mock <IStreamableKeyValuePersistenceService>(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); IXmlSerializationService xmlSerializationService = new XmlSerializationService(); Mock <IOrgProviderService> orgProviderService = new Mock <IOrgProviderService>(); Mock <ILarsProviderService> larsProviderService = new Mock <ILarsProviderService>(); Mock <IPostcodeProviderService> postcodeProverServiceMock = new Mock <IPostcodeProviderService>(); Mock <ILargeEmployerProviderService> largeEmployerProviderService = new Mock <ILargeEmployerProviderService>(); Mock <IDateTimeProvider> dateTimeProviderMock = new Mock <IDateTimeProvider>(); IIntUtilitiesService intUtilitiesService = new IntUtilitiesService(); EasConfiguration easConfiguration = new EasConfiguration() { EasConnectionString = new TestConfigurationHelper().GetSectionValues <EasConfiguration>("EasSection").EasConnectionString }; DataStoreConfiguration dataStoreConfiguration = new DataStoreConfiguration() { ILRDataStoreConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreConnectionString, ILRDataStoreValidConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreValidConnectionString }; IIlr1819ValidContext IlrValidContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntitiesValid>().UseSqlServer(dataStoreConfiguration.ILRDataStoreValidConnectionString).Options; return(new ILR1819_DataStoreEntitiesValid(options)); } IIlr1819RulebaseContext IlrRulebaseContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntities>().UseSqlServer(dataStoreConfiguration.ILRDataStoreConnectionString).Options; return(new ILR1819_DataStoreEntities(options)); } IIlrProviderService ilrProviderService = new IlrFileServiceProvider(logger.Object, storage.Object, xmlSerializationService); IIlrMetadataProviderService ilrMetadataProviderService = new IlrMetadataProviderService(dateTimeProviderMock.Object, IlrValidContextFactory, IlrRulebaseContextFactory); IVersionInfo versionInfo = new VersionInfo { ServiceReleaseVersion = "1.2.3.4.5" }; storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); storage.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead("ILR-10033670-1819-20181213-230923-03.xml").CopyTo(sr)).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.csv", It.IsAny <string>(), It.IsAny <CancellationToken>())).Callback <string, string, CancellationToken>((key, value, ct) => csv = value).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.xlsx", It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>( (key, value, ct) => { value.Seek(0, SeekOrigin.Begin); using (MemoryStream ms = new MemoryStream()) { value.CopyTo(ms); xlsx = ms.ToArray(); } }) .Returns(Task.CompletedTask); storage.Setup(x => x.GetAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(jsonSerializationService.Serialize( new List <string> { "0fm2501", "0fm2502", "0fm2503", "0fm2504" })); storage.Setup(x => x.GetAsync("FundingFm25Output", It.IsAny <CancellationToken>())).ReturnsAsync(File.ReadAllText("Fm25.json")); storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(dateTime); dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(It.IsAny <DateTime>())).Returns(dateTime); largeEmployerProviderService.Setup(x => x.GetVersionAsync(It.IsAny <CancellationToken>())).ReturnsAsync("NA"); postcodeProverServiceMock.Setup(x => x.GetVersionAsync(It.IsAny <CancellationToken>())).ReturnsAsync("NA"); orgProviderService.Setup(x => x.GetProviderName(It.IsAny <IReportServiceContext>(), It.IsAny <CancellationToken>())).ReturnsAsync("Test Provider"); IValueProvider valueProvider = new ValueProvider(); Mock <IFM25ProviderService> fm25ProviderServiceMock = new Mock <IFM25ProviderService>(); var fm25DataModelMock = TestFm25GlobalBuilder.BuildTestModel(); Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10033670); reportServiceContextMock.SetupGet(x => x.Filename).Returns("ILR-10033670-1819-20181213-230923-03"); reportServiceContextMock.SetupGet(x => x.ValidLearnRefNumbersKey).Returns("ValidLearnRefNumbers"); reportServiceContextMock.SetupGet(x => x.FundingFM25OutputKey).Returns("FundingFm25Output"); reportServiceContextMock.SetupGet(x => x.CollectionName).Returns("ILR1819"); fm25ProviderServiceMock.Setup(x => x.GetFM25Data(reportServiceContextMock.Object, CancellationToken.None)).Returns(Task.FromResult(fm25DataModelMock)); decimal?cofTestValue = 100.50m; orgProviderService .Setup(x => x.GetCofRemoval(It.IsAny <IReportServiceContext>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(cofTestValue)); FundingClaim1619Report fundingClaim1619Report = new FundingClaim1619Report( storage.Object, dateTimeProviderMock.Object, valueProvider, ilrProviderService, ilrMetadataProviderService, orgProviderService.Object, fm25ProviderServiceMock.Object, postcodeProverServiceMock.Object, largeEmployerProviderService.Object, larsProviderService.Object, versionInfo, logger.Object); MemoryStream memoryStream = new MemoryStream(); using (memoryStream) { using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Update, true)) { await fundingClaim1619Report.GenerateReport(reportServiceContextMock.Object, archive, false, CancellationToken.None); } using (var fileStream = new FileStream($"{filename}.zip", FileMode.Create)) { memoryStream.Seek(0, SeekOrigin.Begin); memoryStream.CopyTo(fileStream); } } xlsx.Should().NotBeNullOrEmpty(); File.WriteAllBytes($"{filename}.xlsx", xlsx); //using (var stream = File.Open($"{filename}.xlsx", FileMode.Open, FileAccess.Read)) //{ // using (var reader = ExcelReaderFactory.CreateReader(stream)) // { // var result = reader.AsDataSet(); // var a = 1; // } //} }
public async Task TestFundingSummaryReportGeneration() { string csv = string.Empty; byte[] xlsx = null; DateTime dateTime = DateTime.UtcNow; string filename = $"10033670_1_Funding Summary Report {dateTime:yyyyMMdd-HHmmss}"; DataStoreConfiguration dataStoreConfiguration = new DataStoreConfiguration() { ILRDataStoreConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreConnectionString, ILRDataStoreValidConnectionString = new TestConfigurationHelper().GetSectionValues <DataStoreConfiguration>("DataStoreSection").ILRDataStoreValidConnectionString }; IIlr1819ValidContext IlrValidContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntitiesValid>().UseSqlServer(dataStoreConfiguration.ILRDataStoreValidConnectionString).Options; return(new ILR1819_DataStoreEntitiesValid(options)); } IIlr1819RulebaseContext IlrRulebaseContextFactory() { var options = new DbContextOptionsBuilder <ILR1819_DataStoreEntities>().UseSqlServer(dataStoreConfiguration.ILRDataStoreConnectionString).Options; return(new ILR1819_DataStoreEntities(options)); } Mock <ILogger> logger = new Mock <ILogger>(); Mock <IDateTimeProvider> dateTimeProviderMock = new Mock <IDateTimeProvider>(); Mock <IStreamableKeyValuePersistenceService> storage = new Mock <IStreamableKeyValuePersistenceService>(); Mock <IStreamableKeyValuePersistenceService> redis = new Mock <IStreamableKeyValuePersistenceService>(); IIntUtilitiesService intUtilitiesService = new IntUtilitiesService(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); IXmlSerializationService xmlSerializationService = new XmlSerializationService(); IIlrProviderService ilrProviderService = new IlrProviderService(logger.Object, storage.Object, xmlSerializationService, dateTimeProviderMock.Object, intUtilitiesService, IlrValidContextFactory, IlrRulebaseContextFactory); IOrgProviderService orgProviderService = new OrgProviderService(logger.Object, new OrgConfiguration() { OrgConnectionString = ConfigurationManager.AppSettings["OrgConnectionString"] }); ILarsProviderService larsProviderService = new LarsProviderService(logger.Object, new LarsConfiguration() { LarsConnectionString = ConfigurationManager.AppSettings["LarsConnectionString"] }); IEasProviderService easProviderService = new EasProviderService(logger.Object, new EasConfiguration() { EasConnectionString = new TestConfigurationHelper().GetSectionValues <EasConfiguration>("EasSection").EasConnectionString }); Mock <IPostcodeProviderService> postcodeProverServiceMock = new Mock <IPostcodeProviderService>(); Mock <ILargeEmployerProviderService> largeEmployerProviderService = new Mock <ILargeEmployerProviderService>(); IAllbProviderService allbProviderService = new AllbProviderService(logger.Object, redis.Object, jsonSerializationService, intUtilitiesService, IlrValidContextFactory, IlrRulebaseContextFactory); IFM35ProviderService fm35ProviderService = new FM35ProviderService(logger.Object, redis.Object, jsonSerializationService, intUtilitiesService, IlrValidContextFactory, IlrRulebaseContextFactory); IFM25ProviderService fm25ProviderService = new FM25ProviderService(logger.Object, storage.Object, jsonSerializationService, intUtilitiesService, IlrRulebaseContextFactory); IFM36ProviderService fm36ProviderService = new FM36ProviderService(logger.Object, storage.Object, jsonSerializationService, intUtilitiesService, IlrRulebaseContextFactory); IFM81TrailBlazerProviderService fm81TrailBlazerProviderService = new FM81TrailBlazerProviderService(logger.Object, storage.Object, jsonSerializationService, intUtilitiesService, IlrValidContextFactory, IlrRulebaseContextFactory); Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10033670); reportServiceContextMock.SetupGet(x => x.Filename).Returns("ILR-10033670-1819-20180704-120055-03"); reportServiceContextMock.SetupGet(x => x.FundingALBOutputKey).Returns("FundingAlbOutput"); reportServiceContextMock.SetupGet(x => x.FundingFM35OutputKey).Returns("FundingFm35Output"); reportServiceContextMock.SetupGet(x => x.FundingFM25OutputKey).Returns("FundingFm25Output"); reportServiceContextMock.SetupGet(x => x.ValidLearnRefNumbersKey).Returns("ValidLearnRefNumbers"); reportServiceContextMock.SetupGet(x => x.CollectionName).Returns("ILR1819"); reportServiceContextMock.SetupGet(x => x.ReturnPeriod).Returns(12); IValidLearnersService validLearnersService = new ValidLearnersService(logger.Object, redis.Object, jsonSerializationService, dataStoreConfiguration); IStringUtilitiesService stringUtilitiesService = new StringUtilitiesService(); IVersionInfo versionInfo = new VersionInfo { ServiceReleaseVersion = "1.2.3.4.5" }; ITotalBuilder totalBuilder = new TotalBuilder(); IFm25Builder fm25Builder = new Fm25Builder(); IFm35Builder fm35Builder = new Fm35Builder(totalBuilder, new CacheProviderService <LearningDelivery[]>()); IFm36Builder fm36Builder = new Fm36Builder(totalBuilder, new CacheProviderService <ILR.FundingService.FM36.FundingOutput.Model.Output.LearningDelivery[]>()); IFm81Builder fm81Builder = new Fm81Builder(totalBuilder, new CacheProviderService <ILR.FundingService.FM81.FundingOutput.Model.Output.LearningDelivery[]>()); IAllbBuilder allbBuilder = new AllbBuilder(ilrProviderService, validLearnersService, allbProviderService, stringUtilitiesService, logger.Object); IExcelStyleProvider excelStyleProvider = new ExcelStyleProvider(); IEasBuilder easBuilder = new EasBuilder(easProviderService); storage.Setup(x => x.GetAsync("ILR-10033670-1819-20180704-120055-03", It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead("ILR-10033670-1819-20180704-120055-03.xml").CopyTo(sr)).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.csv", It.IsAny <string>(), It.IsAny <CancellationToken>())).Callback <string, string, CancellationToken>((key, value, ct) => csv = value).Returns(Task.CompletedTask); storage.Setup(x => x.SaveAsync($"{filename}.xlsx", It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>( (key, value, ct) => { value.Seek(0, SeekOrigin.Begin); using (MemoryStream ms = new MemoryStream()) { value.CopyTo(ms); xlsx = ms.ToArray(); } }) .Returns(Task.CompletedTask); storage.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.ContainsAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(true); redis.Setup(x => x.GetAsync("FundingALBOutputKey", It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead("ALBOutput1000.json").CopyTo(sr)).Returns(Task.CompletedTask); redis.Setup(x => x.GetAsync("ValidLearnRefNumbers", It.IsAny <CancellationToken>())).ReturnsAsync(jsonSerializationService.Serialize( new List <string> { "3Addl103", "4Addl103" })); redis.Setup(x => x.GetAsync("FundingFm35Output", It.IsAny <Stream>(), It.IsAny <CancellationToken>())).Callback <string, Stream, CancellationToken>((st, sr, ct) => File.OpenRead("Fm35.json").CopyTo(sr)).Returns(Task.CompletedTask); redis.Setup(x => x.GetAsync("FundingFm25Output", It.IsAny <CancellationToken>())).ReturnsAsync(File.ReadAllText("Fm25.json")); dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(dateTime); dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(It.IsAny <DateTime>())).Returns(dateTime); largeEmployerProviderService.Setup(x => x.GetVersionAsync(It.IsAny <CancellationToken>())) .ReturnsAsync("NA"); postcodeProverServiceMock.Setup(x => x.GetVersionAsync(It.IsAny <CancellationToken>())).ReturnsAsync("NA"); ITopicAndTaskSectionOptions topicsAndTasks = TestConfigurationHelper.GetTopicsAndTasks(); IValueProvider valueProvider = new ValueProvider(); FundingSummaryReport fundingSummaryReport = new FundingSummaryReport( storage.Object, ilrProviderService, orgProviderService, allbProviderService, fm25ProviderService, fm35ProviderService, fm36ProviderService, fm81TrailBlazerProviderService, validLearnersService, dateTimeProviderMock.Object, valueProvider, larsProviderService, easProviderService, postcodeProverServiceMock.Object, largeEmployerProviderService.Object, allbBuilder, fm25Builder, fm35Builder, fm36Builder, fm81Builder, totalBuilder, versionInfo, excelStyleProvider, topicsAndTasks, easBuilder, logger.Object); await fundingSummaryReport.GenerateReport(reportServiceContextMock.Object, null, false, CancellationToken.None); csv.Should().NotBeNullOrEmpty(); xlsx.Should().NotBeNullOrEmpty(); #if DEBUG File.WriteAllBytes($"{filename}.xlsx", xlsx); #endif //var fundingSummaryHeaderMapper = new FundingSummaryHeaderMapper(); //var fundingSummaryMapper = new FundingSummaryMapper(); //var fundingSummaryFooterMapper = new FundingSummaryFooterMapper(); //TestCsvHelper.CheckCsv( // csv, // new CsvEntry(fundingSummaryHeaderMapper, 1), // new CsvEntry(fundingSummaryMapper, 0, "16-18 Traineeships Budget", 1), // new CsvEntry(fundingSummaryMapper, 3, "16-18 Traineeships"), // new CsvEntry(fundingSummaryMapper, 1, "16-18 Trailblazer Apprenticeships for starts before 1 May 2017", 1), // new CsvEntry(fundingSummaryMapper, 0, "Advanced Loans Bursary Budget", 1), // new CsvEntry(fundingSummaryMapper, 3, "Advanced Loans Bursary"), // new CsvEntry(fundingSummaryMapper, 0, Constants.ALBInfoText), // new CsvEntry(fundingSummaryFooterMapper, 1, blankRowsBefore: 1)); //var fundingSummaryHeaderMapper = new FundingSummaryHeaderMapper(); //var fundingSummaryMapper = new FundingSummaryMapper(); //TestXlsxHelper.CheckXlsxWithTitles( // xlsx, // new XlsxEntry(fundingSummaryHeaderMapper, fundingSummaryHeaderMapper.GetMaxIndex(), true), // new XlsxEntry(fundingSummaryMapper, 0, "16-18 Traineeships Budget", 1), // new XlsxEntry(fundingSummaryMapper, 13, "16-18 Traineeships", 0), // new XlsxEntry(fundingSummaryMapper, 0, "Carry-in Apprenticeships Budget (for starts before 1 May 2017 and non-procured delivery)", 1), // new XlsxEntry(fundingSummaryMapper, 9, "16-18 Apprenticeship Frameworks for starts before 1 May 2017", 1), // new XlsxEntry(fundingSummaryMapper, 9, "16-18 Trailblazer Apprenticeships for starts before 1 May 2017", 1), // new XlsxEntry(fundingSummaryMapper, 18, "16-18 Non-Levy Contracted Apprenticeships - Non-procured delivery", 1), // new XlsxEntry(fundingSummaryMapper, 9, "19-23 Apprenticeship Frameworks for starts before 1 May 2017", 1), // new XlsxEntry(fundingSummaryMapper, 9, "19-23 Trailblazer Apprenticeships for starts before 1 May 2017", 0), // new XlsxEntry(fundingSummaryMapper, 9, "24+ Apprenticeship Frameworks for starts before 1 May 2017", 1)); }