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); }
public void Export_passes_in_used_parameters_to_file() { // Given const string searchString = "Frame by Frame"; const string sortBy = "Discipline"; const string sortDirection = "The Sheltering Sky"; const string filters = "Indiscipline"; var centreId = allDelegatesController.User.GetCentreId(); // When allDelegatesController.Export(searchString, sortBy, sortDirection, filters); // Then A.CallTo( () => delegateDownloadFileService.GetAllDelegatesFileForCentre( centreId, searchString, sortBy, sortDirection, filters ) ).MustHaveHappenedOnceExactly(); }
public IActionResult Export( string?searchString = null, string?sortBy = null, string sortDirection = GenericSortingHelper.Ascending, string?existingFilterString = null ) { var centreId = User.GetCentreId(); var content = delegateDownloadFileService.GetAllDelegatesFileForCentre( centreId, searchString, sortBy, sortDirection, existingFilterString ); const string fileName = "Digital Learning Solutions Delegates.xlsx"; return(File( content, FileHelper.GetContentTypeFromFileName(fileName), fileName )); }