public void TestSetup() { var mockPDFManager = new Mock <IPDFManager>(); getPDFFieldsResponse = new List <PDFField>() { new PDFField() { Name = "VOAFieldOne" }, new PDFField() { Name = "VOAFieldTwo" }, new PDFField() { Name = "VOAFieldThree" } }; mockPDFManager.Setup(x => x.GetPDFields(String.Empty, String.Empty)).ReturnsAsync(getPDFFieldsResponse); FileNameManager fileNameManager = new FileNameManager(); DataManager dataManager = new DataManager(null, null); DataConnector <IVOAType> dataConnector = new DataConnector <IVOAType>(); mainWindowViewModel = new MainWindowViewModel(mockPDFManager.Object, new IOManager(fileNameManager), fileNameManager, dataManager, dataConnector, new CSVManager(new CSVRepository(), new IOManager(new FileNameManager()))); mainWindowViewModel.Prefix = ""; mainWindowViewModel.TemplatePath = ""; }
public static void Main() { Console.WriteLine(FileNameManager.GetFileExtension("example")); Console.WriteLine(FileNameManager.GetFileExtension("example.pdf")); Console.WriteLine(FileNameManager.GetFileExtension("example.new.pdf")); Console.WriteLine(FileNameManager.GetFileNameWithoutExtension("example")); Console.WriteLine(FileNameManager.GetFileNameWithoutExtension("example.pdf")); Console.WriteLine(FileNameManager.GetFileNameWithoutExtension("example.new.pdf")); Console.WriteLine( "Distance in the 2D space = {0:f2}", DistanceCalculator.CalcDistance2D(1, -2, 3, 4)); Console.WriteLine( "Distance in the 3D space = {0:f2}", DistanceCalculator.CalcDistance3D(5, 2, -1, 3, -6, 4)); double width = 3; double height = 4; double depth = 5; var figure3D = new Figure3D(width, height, depth); Console.WriteLine("Volume = {0:f2}", figure3D.CalcVolume()); Console.WriteLine("Diagonal XYZ = {0:f2}", figure3D.CalcDiagonalXYZ()); Console.WriteLine("Diagonal XY = {0:f2}", figure3D.CalcDiagonalXY()); Console.WriteLine("Diagonal XZ = {0:f2}", figure3D.CalcDiagonalXZ()); Console.WriteLine("Diagonal YZ = {0:f2}", figure3D.CalcDiagonalYZ()); }
public void TestSetup() { IFileNameManager fileNameManager = new FileNameManager(); IIOManager ioManager = new IOManager(fileNameManager); ICSVRepository csvRepository = new CSVRepository(); csvManager = new CSVManager(csvRepository, ioManager); }
public FileNameManagerTests() { _fileSystem = new FileSystemBuilder().AddDirectoryInfo(DummyDirectories.defaultsFolder) .AddDirectoryInfo(DummyDirectories.documentsFolder) .AddDirectoryInfo(DummyDirectories.presentationsFolder) .Build(); _fileNameManager = new FileNameManager(_fileSystem); }
private ResponseModel StepOneValidation(ResponseModel rm, IFormFileCollection files, BatchHead form) { List <ValidateDataModel> messages = new List <ValidateDataModel>(); List <ProjectFiles> pfs = GetProjectFiles(form.ProjectID); try { foreach (ProjectFiles pf in pfs) { foreach (IFormFile f in files) { if (FileNameManager.FileName(f.FileName).Length >= pf.FileID.Length) //cant slip in a file name with 3 char and substring 10 char from it. { if (FileNameManager.FileName(f.FileName).Substring(0, pf.FileID.Length).ToLower() == pf.FileID.ToLower()) {//If the file matches to its FileID then its added to _files for upload _files.Add(new Files { FileID = pf.FileID, LatestFileName = FileNameManager.FileName(f.FileName), File = f, FileProperties = GetFileProperties(form.ProjectID, pf.FileID) }); //if the same file has been added twice then return the error message if (_files.FindAll(x => x.LatestFileName.ToLower().Contains(pf.FileID.ToLower())).Count > 1) { MessageValidationManager.Check(ref messages, $"Upload cannot contain duplicate {pf.FileID} files."); } } } } } } catch (Exception ex) { Console.Write(ex.Message); } //This checks if any files exist in the uploaded batch but not in _files collection that is valid based on the database FileID values foreach (IFormFile f in files) { if (!FileNameManager.FileName(f.FileName).ToLower().Contains(".csv")) { MessageValidationManager.Check(ref messages, $"<span class='file-col'>{FileNameManager.FileName(f.FileName)}</span> is not a valid file format. Must be .csv."); } else if (!_files.Exists(s => s.LatestFileName == FileNameManager.FileName(f.FileName))) { MessageValidationManager.Check(ref messages, $"<span class='file-col'>{FileNameManager.FileName(f.FileName)}</span> has an incorrect file name. It must begin one of the following words: {ConvertToFileListString(pfs)}."); } } rm.messages = messages; return(rm); }
public static string GetFileExtension(string fileName) { FileNameManager.ValidateFileName(fileName); int indexOfLastDot = fileName.LastIndexOf("."); if (indexOfLastDot == -1) { return(string.Empty); } string extension = fileName.Substring(indexOfLastDot + 1); return(extension); }
private System.Guid StartUpload(BatchHead form) { System.Guid uploadID; try { using (IDbConnection db = new SqlConnection(_configuration.GetConnectionString("4CE"))) { db.Open(); var p = new DynamicParameters(); p.Add("@ProjectID", form.ProjectID, dbType: DbType.String); p.Add("@SiteID", form.SiteID, dbType: DbType.String); p.Add("@PersonName", form.PersonsName, dbType: DbType.String); p.Add("@Email", form.Email, dbType: DbType.String); int i = 1; foreach (Models.Files file in _files) { p.Add("@OriginalFileName" + i, FileNameManager.FileName(file.File.FileName), dbType: DbType.String); p.Add("@FileID" + i, file.FileID, dbType: DbType.String); i++; if (i >= 9) { break; } } p.Add("Status", "", dbType: DbType.String, ParameterDirection.Output); List <StartUploadResults> l = new List <StartUploadResults>(); l = db.Query <StartUploadResults>("[dbo].[uspStartUpload]", p, commandType: CommandType.StoredProcedure).ToList(); StartUploadResults r = l.First(); if (r.ArchiveFileName1 != null) { _files[0].ArchiveFileName = r.ArchiveFileName1; _files[0].LatestFileName = r.LatestFileName1; } if (r.ArchiveFileName2 != null) { _files[1].ArchiveFileName = r.ArchiveFileName2; _files[1].LatestFileName = r.LatestFileName2; } if (r.ArchiveFileName3 != null) { _files[2].ArchiveFileName = r.ArchiveFileName3; _files[2].LatestFileName = r.LatestFileName3; } if (r.ArchiveFileName4 != null) { _files[3].ArchiveFileName = r.ArchiveFileName4; _files[3].LatestFileName = r.LatestFileName4; } if (r.ArchiveFileName5 != null) { _files[4].ArchiveFileName = r.ArchiveFileName5; _files[4].LatestFileName = r.LatestFileName5; } if (r.ArchiveFileName6 != null) { _files[5].ArchiveFileName = r.ArchiveFileName6; _files[5].LatestFileName = r.LatestFileName6; } if (r.ArchiveFileName7 != null) { _files[6].ArchiveFileName = r.ArchiveFileName7; _files[6].LatestFileName = r.LatestFileName7; } if (r.ArchiveFileName8 != null) { _files[7].ArchiveFileName = r.ArchiveFileName8; _files[7].LatestFileName = r.LatestFileName8; } if (r.ArchiveFileName9 != null) { _files[8].ArchiveFileName = r.ArchiveFileName9; _files[8].LatestFileName = r.LatestFileName9; } uploadID = r.UploadID; db.Close(); } } catch (Exception e) { return(new System.Guid()); } return(uploadID); }