/// <summary> /// Calibration file is optional for nonThreeDReady projects /// cws Filename format is: "trn::profilex:us-west-2:project:5d2ab210-5fb4-4e77-90f9-b0b41c9e6e3f||2020-03-25 23:03:45.314||BootCamp 2012.dc", /// </summary> public static bool ExtractCalibrationFileDetails(List <ProjectConfigurationModel> projectConfigurations, out string fileName, out DateTime?fileDateUtc) { fileName = string.Empty; fileDateUtc = null; var projectConfiguration = projectConfigurations?.FirstOrDefault(c => c.FileType == ProjectConfigurationFileType.CALIBRATION.ToString()); if (projectConfiguration == null) { return(false); } var parts = projectConfiguration.FileName.Split(ProjectConfigurationModel.FilenamePathSeparator); if (parts.Length == 3) { fileName = parts[2].Trim(); var acceptedFileExtensions = new AcceptedFileExtensions(); if ((!acceptedFileExtensions.IsExtensionAllowed(new List <string> { "dc", "cal" }, fileName)) || (!DateTime.TryParse(parts[1], out var fileDate))) { return(false); } fileDateUtc = fileDate; return(true); } return(false); }
public void ExtensionInvalid_NoExtension() { var tester = new AcceptedFileExtensions(); var acceptedExtensions = new List <string> { "txt", "png", "pdf" }; var result = tester.IsExtensionAllowed(acceptedExtensions, "test"); Assert.IsFalse(result); }
public void ExtensionAccepted_DifferentCase() { var tester = new AcceptedFileExtensions(); var acceptedExtensions = new List <string> { "txt", "png", "pdf" }; var result = tester.IsExtensionAllowed(acceptedExtensions, "test.TXT"); Assert.IsTrue(result); }