示例#1
0
        public void GetAllDelegatesFileForCentre_returns_expected_excel_data()
        {
            // TODO: HEEDLS-810 - run the formatter once review complete.
            // Given
            const int centreId = 2;

            var centreRegistrationPrompts = new List <CentreRegistrationPrompt>
            {
                new CentreRegistrationPrompt(RegistrationField.CentreRegistrationField1, 1, "Role type", null, true),
                new CentreRegistrationPrompt(RegistrationField.CentreRegistrationField2, 2, "Manager", null, true),
                new CentreRegistrationPrompt(RegistrationField.CentreRegistrationField3, 3, "Base / office / place of work", null, true),
                new CentreRegistrationPrompt(RegistrationField.CentreRegistrationField4, 4, "Base / office / place of work", null, true),
                new CentreRegistrationPrompt(RegistrationField.CentreRegistrationField5, 5, "Contact telephone number", null, true),
            };

            A.CallTo(() => centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId))
            .Returns(new CentreRegistrationPrompts(centreId, centreRegistrationPrompts));

            A.CallTo(() => userDataService.GetDelegateUserCardsByCentreId(2)).Returns(delegateUserCards);

            // When
            var resultBytes = delegateDownloadFileService.GetAllDelegatesFileForCentre(2, null, null, GenericSortingHelper.Ascending, null);

            using var resultsStream  = new MemoryStream(resultBytes);
            using var resultWorkbook = new XLWorkbook(resultsStream);

            // Then
            using var expectedWorkbook = new XLWorkbook(
                      TestContext.CurrentContext.TestDirectory + TestAllDelegatesExportRelativeFilePath
                      );
            SpreadsheetTestHelper.AssertSpreadsheetsAreEquivalent(expectedWorkbook, resultWorkbook);
        }
示例#2
0
        public void GetEvaluationSummaryFileForCentre_returns_expected_excel_data()
        {
            // Given
            using var expectedWorkbook = new XLWorkbook(
                      TestContext.CurrentContext.TestDirectory + EvaluationSummaryDownloadRelativeFilePath
                      );
            GivenEvaluationSummaryDataServiceReturnsDataInExampleSheet();

            var filterData = new ActivityFilterData(
                DateTime.Parse("2020-9-1"),
                DateTime.Parse("2021-9-1"),
                null,
                null,
                null,
                CourseFilterType.None,
                ReportInterval.Months
                );

            // When
            var resultBytes = evaluationSummaryService.GetEvaluationSummaryFileForCentre(101, filterData);

            using var resultsStream  = new MemoryStream(resultBytes);
            using var resultWorkbook = new XLWorkbook(resultsStream);

            // Then
            SpreadsheetTestHelper.AssertSpreadsheetsAreEquivalent(expectedWorkbook, resultWorkbook);
        }
示例#3
0
        public void GetCourseDelegateDownloadFile_returns_expected_excel_data()
        {
            // Given
            const int categoryId = 1;
            const int centreId   = 1;

            using var expectedWorkbook = new XLWorkbook(
                      TestContext.CurrentContext.TestDirectory + CourseDelegateExportAllDataDownloadRelativeFilePath
                      );

            A.CallTo(() => courseService.GetCentreCourseDetailsWithAllCentreCourses(centreId, categoryId)).Returns(
                new CentreCourseDetails
            {
                Courses = new[]
                {
                    new CourseStatisticsWithAdminFieldResponseCounts
                    {
                        ApplicationName = "Course One", CustomisationName = "v1", CustomisationId = 1
                    },
                    new CourseStatisticsWithAdminFieldResponseCounts
                    {
                        ApplicationName = "Course Two", CustomisationName = "v1", CustomisationId = 2
                    },
                },
            }
                );

            A.CallTo(() => courseDataService.GetDelegatesOnCourseForExport(1, centreId))
            .Returns(courseDelegates.Where(c => c.ApplicationName == "Course One"));
            A.CallTo(() => courseDataService.GetDelegatesOnCourseForExport(2, centreId))
            .Returns(courseDelegates.Where(c => c.ApplicationName == "Course Two"));

            var centreRegistrationPrompts = new List <CentreRegistrationPrompt>
            {
                new CentreRegistrationPrompt(1, 1, "Role type", null, true),
                new CentreRegistrationPrompt(2, 2, "Manager", null, true),
                new CentreRegistrationPrompt(3, 3, "Base / office / place of work", null, true),
                new CentreRegistrationPrompt(4, 4, "Base / office / place of work", null, true),
                new CentreRegistrationPrompt(5, 5, "Contact telephone number", null, true),
            };

            A.CallTo(() => registrationPromptsService.GetCentreRegistrationPromptsByCentreId(centreId))
            .Returns(new CentreRegistrationPrompts(centreId, centreRegistrationPrompts));

            // When
            var resultBytes = courseDelegatesDownloadFileService.GetCourseDelegateDownloadFile(
                centreId,
                categoryId,
                null,
                null,
                null
                );

            using var resultsStream  = new MemoryStream(resultBytes);
            using var resultWorkbook = new XLWorkbook(resultsStream);

            // Then
            SpreadsheetTestHelper.AssertSpreadsheetsAreEquivalent(expectedWorkbook, resultWorkbook);
        }
示例#4
0
        public void GetDelegatesAndJobGroupDownloadFileForCentre_returns_expected_excel_data()
        {
            // Given
            A.CallTo(() => jobGroupsDataService.GetJobGroupsAlphabetical()).Returns(
                JobGroupsTestHelper.GetDefaultJobGroupsAlphabetical()
                );

            A.CallTo(() => userDataService.GetDelegateUserCardsByCentreId(2)).Returns(delegateUserCards);

            // When
            var resultBytes = delegateDownloadFileService.GetDelegatesAndJobGroupDownloadFileForCentre(2);

            using var resultsStream  = new MemoryStream(resultBytes);
            using var resultWorkbook = new XLWorkbook(resultsStream);

            // Then
            using var expectedWorkbook = new XLWorkbook(
                      TestContext.CurrentContext.TestDirectory + DelegateUploadFileServiceTests.TestDelegateUploadRelativeFilePath
                      );
            SpreadsheetTestHelper.AssertSpreadsheetsAreEquivalent(expectedWorkbook, resultWorkbook);
        }