public void Test001BreakoutWithFileAndExtensionOnly() { var testStr = @"SomefileName.txt"; var expectedResult = @"SomefileName.txt"; var filePathDto = new FilePathDto(testStr); Assert.IsTrue(filePathDto.FileNameAndExtension == expectedResult); }
public void Test005ParseFullPath() { var testStr = @"D:\Level1\Level2\SomefileName.txt"; var expectedDirPath = @"D:\Level1\Level2\SomefileName.txt"; var filePathDto = new FilePathDto(testStr); Assert.IsTrue(filePathDto.FullPathAndFileName == expectedDirPath); }
public void Test004ParseDirOnlyNoTrailingSlash() { var testStr = @"D:\Level1\Level2"; var expectedDirPath = @"D:\Level1"; var filePathDto = new FilePathDto(testStr); Assert.IsTrue(filePathDto.DirectoryPath == expectedDirPath); }
public void Test006ParseFullPathOnRelativePath() { var fInfo = new FileInfo("SomefileName.txt"); var testStr = @".\SomefileName.txt"; var expectedDirPath = fInfo.FullName; var filePathDto = new FilePathDto(testStr); Assert.IsTrue(filePathDto.FullPathAndFileName == expectedDirPath); }
public ActionResult <string[]> SearchLogsPerDirectory14(FilePathDto file) { var response = ReadTextFilesService.SearchLogsPerDirectory14(file.filePath); if (response is null) { return(BadRequest()); } return(Ok(response)); }
public ActionResult <List <Duplicate> > ReadFile12(FilePathDto file) { var response = ReadTextFilesService.ReadFile12(file.filePath); if (response is null) { return(BadRequest()); } return(Ok(response)); }
public async System.Threading.Tasks.Task ConvertExcelFileToTextFileTest_FileTestShouldExistAsync() { string myPathFromExcelFile = $"..\\..\\..\\FilesTest\\ArchivoCinte2021.xlsx"; FilePathDto filePath = new FilePathDto { MyPathFromExcelFile = myPathFromExcelFile }; FileService fileService = new FileService(); bool response = await fileService.ConvertExcelFileToTextFile(filePath); Assert.AreEqual(true, response); }
public void Test007ChangeFileNameShouldProcessSuccessfully() { var testStr = @"D:\Level1\Level2\SomefileName.txt"; var filePathDto = new FilePathDto(testStr); filePathDto.SetFileNameOnly("SomeOtherFileName"); var expectedDirPath = @"D:\Level1\Level2\SomeOtherFileName.txt"; Assert.IsTrue(filePathDto.FullPathAndFileName == expectedDirPath); Assert.IsTrue(filePathDto.FileNameAndExtension == "SomeOtherFileName.txt"); Assert.IsTrue(filePathDto.Extension == ".txt"); Assert.IsTrue(filePathDto.ExtensionWithoutLeadingDot == "txt"); }
public async Task <IActionResult> ConvertExcelFileToTextFile([FromBody] FilePathDto filePath) { try { await _fileService.ConvertExcelFileToTextFile(filePath); return(Ok("The text file has been created.")); } catch (Exception e) { Console.WriteLine(e); return(StatusCode(404, e.Message.ToString())); } }
public void Test002ParseValidFilePathCorrectly() { var testStr = @"D:\Level1\Level2\SomefileName.txt"; var expectedFileNameAndExt = @"SomefileName.txt"; var expectedExt = @".txt"; var expectedFileNameOnly = @"SomefileName"; var expectedDirPath = @"D:\Level1\Level2"; var filePathDto = new FilePathDto(testStr); Assert.IsTrue(filePathDto.FileNameAndExtension == expectedFileNameAndExt); Assert.IsTrue(filePathDto.DirectoryPath == expectedDirPath); Assert.IsTrue(filePathDto.FileNameOnly == expectedFileNameOnly); Assert.IsTrue(filePathDto.Extension ==expectedExt); }
public async Task <bool> ConvertExcelFileToTextFile(FilePathDto filePath) { Workbook workbook = new Workbook(); try { string myDirectoryToTextFile = $"{Directory.GetCurrentDirectory()}\\Files"; workbook.LoadFromFile(filePath.MyPathFromExcelFile); Worksheet sheet = workbook.Worksheets[0]; string pathFileTxtWithoutFormat = $"{myDirectoryToTextFile}\\AWSCinte.txt"; sheet.SaveToFile(pathFileTxtWithoutFormat, "|"); await FormatFileTxt(myDirectoryToTextFile); File.Delete(pathFileTxtWithoutFormat); } catch (Exception) { throw; } return(true); }
public ActionResult <int> CountDuplicate13(FilePathDto file) { var response = ReadTextFilesService.CountDuplicate13(file.filePath); return(Ok(response)); }
private bool ValidateFileInputString(string fileStr) { if (string.IsNullOrWhiteSpace(fileStr)) { return false; } try { _filePathDto = new FilePathDto(fileStr); if (_filePathDto.FileNameAndExtension == string.Empty) { return false; } } catch { return false; } return true; }
public FileDto ExtractLogFileDto(string cmdConsoleLogPathFileName, string logFileTimeStamp) { var filePath = new FilePathDto(cmdConsoleLogPathFileName); var sb = new StringBuilder(); if (filePath.HasDirectoryPath) { sb.Append(Path.Combine(filePath.DirectoryPath, filePath.FileNameOnly)); } else { sb.Append(filePath.FileNameOnly); } sb.Append("_" + logFileTimeStamp); if (filePath.HasExtension) { if (filePath.Extension.Contains(".")) { sb.Append(filePath.Extension); } else { sb.Append("."); sb.Append(filePath.Extension); } } return new FileDto(sb.ToString()); }