//[Fact]
        public async Task SystemTest()
        {
            var container         = "Output";
            var cancellationToken = CancellationToken.None;
            var ukprn             = 10005788;

            var fcsService = new Mock <IFCSProviderService>();

            fcsService.Setup(f => f.GetContractAllocationNumberFSPCodeLookupAsync(ukprn, cancellationToken)).ReturnsAsync(new Dictionary <string, string>());

            var reportServiceContextMock       = new Mock <IReportServiceContext>();
            var periodisedValuesLookupProvider = new Mock <IPeriodisedValuesLookupProviderService>();

            periodisedValuesLookupProvider.Setup(p => p.ProvideAsync(reportServiceContextMock.Object, cancellationToken)).ReturnsAsync(new PeriodisedValuesLookup());

            var referenceDataServiceMock = new Mock <IReferenceDataService>();
            var dateTimeProviderMock     = new Mock <IDateTimeProvider>();
            var persistReportDataMock    = new Mock <IPersistReportData>();

            referenceDataServiceMock
            .Setup(m => m.GetLatestIlrSubmissionFileNameAsync(10005788, It.IsAny <CancellationToken>()))
            .ReturnsAsync("10005788/ILR-10005788-1920-20190801-000001-01.xml");

            var fundingSummaryReportModelBuilder = new FundingSummaryReportModelBuilder(referenceDataServiceMock.Object, dateTimeProviderMock.Object);

            var submissionDateTime = new DateTime(2019, 3, 1);

            reportServiceContextMock.Setup(c => c.Ukprn).Returns(10005788);
            reportServiceContextMock.Setup(c => c.Container).Returns(container);
            reportServiceContextMock.Setup(c => c.SubmissionDateTimeUtc).Returns(submissionDateTime);

            var excelService = new ExcelService(new FileServiceStub());

            dateTimeProviderMock.Setup(p => p.ConvertUtcToUk(submissionDateTime)).Returns(submissionDateTime);

            var fundingSummaryReportRenderService = new FundingSummaryReportRenderService();

            var report = NewReport(
                Mock.Of <ILogger>(),
                Mock.Of <IStreamableKeyValuePersistenceService>(),
                dateTimeProviderMock.Object,
                fundingSummaryReportModelBuilder,
                excelService,
                fundingSummaryReportRenderService,
                periodisedValuesLookupProvider.Object,
                fcsService.Object,
                persistReportDataMock.Object);

            excelService.ApplyLicense();

            using (var memoryStream = new MemoryStream())
            {
                using (var zipArchive = new ZipArchive(memoryStream, ZipArchiveMode.Update))
                {
                    await report.GenerateReport(reportServiceContextMock.Object, zipArchive, cancellationToken);
                }
            }
        }
Exemple #2
0
        public async Task GenerateReport_ThreeFundingYears()
        {
            var ukprn        = 12345678;
            var jobid        = 1;
            var reportFolder = "FundingSummaryTestThreeYears";

            TestFixture(reportFolder, ukprn, jobid);

            var esfJobContext     = new Mock <IEsfJobContext>();
            var sourceFile        = new Mock <ISourceFileModel>();
            var wrapper           = new SupplementaryDataWrapper();
            var cancellationToken = CancellationToken.None;

            var testModels = new List <IFundingSummaryReportTab>
            {
                new FundingSummaryReportTab
                {
                    Title   = FundingSummaryReportConstants.BodyTitle,
                    TabName = "ConRef1",
                    Header  = TestHeader("ConRef1", 3),
                    Body    = TestBodyModels(3),
                    Footer  = TestFooter()
                },
                new FundingSummaryReportTab
                {
                    Title   = FundingSummaryReportConstants.BodyTitle,
                    TabName = "ConRef2",
                    Header  = TestHeader("ConRef2", 3),
                    Body    = TestBodyModels(3),
                    Footer  = TestFooter()
                }
            };

            esfJobContext.Setup(x => x.UkPrn).Returns(ukprn);
            esfJobContext.Setup(x => x.JobId).Returns(jobid);
            esfJobContext.Setup(x => x.StartCollectionYearAbbreviation).Returns("20");
            esfJobContext.Setup(x => x.CollectionYear).Returns(2021);
            esfJobContext.Setup(x => x.ReturnPeriod).Returns("R05");
            esfJobContext.Setup(x => x.CurrentPeriod).Returns(5);
            esfJobContext.Setup(x => x.BlobContainerName).Returns(reportFolder);

            var modelBuilder     = new Mock <IFundingSummaryReportModelBuilder>();
            var renderService    = new FundingSummaryReportRenderService();
            var dateTimeProvider = new Mock <IDateTimeProvider>();
            var fileService      = new FileSystemFileService();
            var excelFileService = new ExcelFileService(fileService);

            modelBuilder.Setup(x => x.Build(esfJobContext.Object, cancellationToken)).ReturnsAsync(testModels);

            await NewReport(modelBuilder.Object, renderService, dateTimeProvider.Object, excelFileService)
            .GenerateReport(esfJobContext.Object, sourceFile.Object, wrapper, cancellationToken);
        }
Exemple #3
0
        public async Task SystemTest()
        {
            var container         = "Output";
            var ukprn             = 123456789;
            var reportGeneratedAt = new DateTime(2019, 03, 03);

            var refDataRoot = new ReferenceDataRoot()
            {
                Organisations = new List <Organisation>()
                {
                    new Organisation()
                    {
                        UKPRN = ukprn,
                        Name  = "OrganisationName"
                    }
                },
                MetaDatas = new MetaData()
                {
                    ReferenceDataVersions = new ReferenceDataVersion()
                    {
                        OrganisationsVersion = new OrganisationsVersion {
                            Version = "orgVersion"
                        },
                        EasFileDetails = new EasFileDetails {
                            UploadDateTime = new DateTime(2019, 01, 01)
                        },
                        LarsVersion = new LarsVersion {
                            Version = "larsVersion"
                        },
                        PostcodesVersion = new PostcodesVersion {
                            Version = "postcodeVersion"
                        },
                        Employers = new EmployersVersion {
                            Version = "employersVersion"
                        }
                    }
                }
            };

            var message = new Message()
            {
                Header = new MessageHeader()
                {
                    CollectionDetails = new MessageHeaderCollectionDetails()
                    {
                        FilePreparationDate = new DateTime(2019, 01, 02)
                    }
                }
            };

            var reportServiceDependentDataMock = new Mock <IReportServiceDependentData>();

            reportServiceDependentDataMock.Setup(x => x.Get <ReferenceDataRoot>()).Returns(refDataRoot);
            reportServiceDependentDataMock.Setup(x => x.Get <IMessage>()).Returns(message);

            var periodisedValuesLookupProvider = new Mock <IPeriodisedValuesLookupProvider>();

            periodisedValuesLookupProvider.Setup(p => p.Provide(It.IsAny <IEnumerable <FundingDataSources> >(), reportServiceDependentDataMock.Object)).Returns(new PeriodisedValuesLookup());

            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(x => x.GetNowUtc()).Returns(reportGeneratedAt);
            dateTimeProviderMock.Setup(x => x.ConvertUtcToUk(reportGeneratedAt)).Returns(reportGeneratedAt);

            var fundingSummaryReportModelBuilder = new DesktopFundingSummaryReportModelBuilder(periodisedValuesLookupProvider.Object, dateTimeProviderMock.Object);

            var reportServiceContextMock = new Mock <IReportServiceContext>();

            reportServiceContextMock.Setup(c => c.Container).Returns(container);
            reportServiceContextMock.Setup(c => c.Ukprn).Returns(ukprn);
            reportServiceContextMock.Setup(c => c.IlrReportingFilename).Returns("ILR-11111111-1920-20190507-152000-01");
            reportServiceContextMock.Setup(c => c.ServiceReleaseVersion).Returns("ServiceReleaseVersion");

            var workBook = new Workbook();

            workBook.Worksheets.Add("FundingSummaryReport");
            var excelService = new Mock <IExcelFileService>();

            excelService.Setup(es => es.NewWorkbook()).Returns(workBook);
            excelService.Setup(es => es.GetWorksheetFromWorkbook(workBook, "FundingSummaryReport")).Returns(workBook.Worksheets["FundingSummaryReport"]);

            var fileNameServiceMock = new Mock <IFileNameService>();

            var fileName = "DesktopFundingSummaryReport.xlsx";

            fileNameServiceMock.Setup(s => s.GetFilename(reportServiceContextMock.Object, "Funding Summary Report", OutputTypes.Excel, true)).Returns(fileName);

            var fundingSummaryReportRenderService = new FundingSummaryReportRenderService();

            var report = NewReport(
                fileNameServiceMock.Object,
                fundingSummaryReportModelBuilder,
                excelService.Object,
                fundingSummaryReportRenderService);

            var cancellationToken = CancellationToken.None;

            await report.GenerateAsync(reportServiceContextMock.Object, reportServiceDependentDataMock.Object, cancellationToken);
        }