public void GetFileWithSpecificAlphabetName() { Assert.Equal("신의 탑.txt", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\신의 탑.txt")); Assert.Equal("鋼の錬金術師.txt", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\鋼の錬金術師.txt")); Assert.Equal("นรางามิ เทวดาขาจร.txt", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\นรางามิ เทวดาขาจร.txt")); Assert.Equal("Тест єії'.txt", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\Тест єії'.txt")); }
public void TestGetFileName(string filename) { string path = testsDirFullPath + "\\" + filename; string realName = BaseFileWorker.GetFileName(path); Assert.Equal(filename, realName); }
public void ReadFileName_ReadsExistingFileName(string fileName, string subdir = null) { if (subdir != null) { Directory.CreateDirectory(subdir); } string subdirOrEmpty = subdir != null ? subdir + "\\" : ""; var path = $"{CurrentDirectory}\\{subdirOrEmpty}{fileName}"; File.WriteAllText(path, ""); string res_fileName = null; Action codeToTest = () => { res_fileName = BaseFileWorker.GetFileName(path); }; var ex = Record.Exception(codeToTest); Assert.Null(ex); Assert.NotNull(res_fileName); Assert.Equal(fileName, res_fileName); File.Delete(path); // cleanup if (subdir != null) { Directory.Delete(subdir); } }
public void GetSpecialFileName() { Assert.Equal("0524.torrent", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\0524.torrent")); Assert.Equal("IIG.Core.FileWorkingUtils.pdb", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\IIG.Core.FileWorkingUtils.pdb")); Assert.Equal("vlc-3.0.10-win64.exe", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\vlc-3.0.10-win64.exe")); Assert.Equal("-73_1_1.zip", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\-73_1_1.zip")); }
public void GetTextFileName() { Assert.Equal("0.5.2.docx", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\0.5.2.docx")); Assert.Equal("Neechy.pptx", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\Neechy.pptx")); Assert.Equal("test.txt", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\test.txt")); Assert.Equal("sds.pdf", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\sds.pdf")); }
public void GetMultimediaFileName() { Assert.Equal("ms18.mp4", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\ms18.mp4")); Assert.Equal("DUSTCELL - DERO.mp3", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\DUSTCELL - DERO.mp3")); Assert.Equal("bell.png", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\bell.png")); Assert.Equal("pexels-photo-4173624.jpeg", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\pexels-photo-4173624.jpeg")); }
public void TestGetFileNameException(string filename) { try { BaseFileWorker.GetFileName(filename); } catch (Exception e) { Assert.NotNull(e); } }
public void TestGetFileNameReturnNull() { //non-existed file Assert.Null(BaseFileWorker.GetFileName(pathToFiles + @"\IIF")); //folder Assert.Null(BaseFileWorker.GetFileName(pathToFiles + "\\empty")); //existed file but with no extension Assert.Null(BaseFileWorker.GetFileName(pathToFiles + @"\test")); }
public void Test_GetFileName_Different_Types() { Assert.AreEqual("1.txt", BaseFileWorker.GetFileName("C:\\TestFiles\\1.txt")); Assert.AreEqual("1.bmp", BaseFileWorker.GetFileName("C:\\TestFiles\\1.bmp")); Assert.AreEqual("1.mpp", BaseFileWorker.GetFileName("C:\\TestFiles\\1.mpp")); Assert.AreEqual("1.odg", BaseFileWorker.GetFileName("C:\\TestFiles\\1.odg")); Assert.AreEqual("1.rar", BaseFileWorker.GetFileName("C:\\TestFiles\\1.rar")); Assert.AreEqual("1.rtf", BaseFileWorker.GetFileName("C:\\TestFiles\\1.rtf")); Assert.AreEqual("1.mp4", BaseFileWorker.GetFileName("C:\\TestFiles\\1.mp4")); }
public void TestSaveBinaryFlagToFileSuccess() { string targetPath = BaseFileWorker.MkDir(TestDirectory); // 1. Test if dir was crated Assert.NotNull(targetPath); bool status1 = BaseFileWorker.TryCopy(InitAbsolutePath, targetPath + "/" + TestFile, true, 10); // 2. Test if file was copied and previous dir was created Assert.True(status1); string fileName = BaseFileWorker.GetFileName(targetPath + "/" + TestFile); // 3. Test if file system if it was created Assert.Equal(TestFile, fileName); string fileText = BaseFileWorker.ReadAll(targetPath + "/" + TestFile); // 4. Test if file was read right Assert.Equal("some test text", fileText); bool flag1 = _MBF.GetFlag(); // 5. Test flag status Assert.True(flag1); _MBF.ResetFlag(SIZE - 2); bool flag2 = _MBF.GetFlag(); // 6. Test flag status after reset Assert.False(flag2); _MBF.SetFlag(SIZE - 2); bool flag3 = _MBF.GetFlag(); // 7. Test flag status after set Assert.True(flag3); bool status2 = BaseFileWorker.TryWrite(flag1.ToString(), targetPath + "/" + TestFile, 10); // Check if previous operation was successful Assert.True(status2); string[] lines1 = BaseFileWorker.ReadLines(targetPath + "/" + TestFile); // 8. Check if writing to file was successful Assert.Equal(lines1[0], true.ToString()); bool status3 = BaseFileWorker.Write(flag2.ToString(), targetPath + "/" + TestFile); // Check if previous operation was successful Assert.True(status3); string[] lines2 = BaseFileWorker.ReadLines(targetPath + "/" + TestFile); // 9. Check if writing to file was successful Assert.Equal(lines2[0], false.ToString()); bool status4 = BaseFileWorker.Write(flag3.ToString(), targetPath + "/" + TestFile); // Check if previous operation was successful Assert.True(status4); string[] lines3 = BaseFileWorker.ReadLines(targetPath + "/" + TestFile); // 10. Check if writing to file was successful Assert.Equal(lines3[0], true.ToString()); }
public void Test_GetFileName_NullPath() { try { const string pathNull = null; string received = BaseFileWorker.GetFileName(pathNull); Assert.IsNull(received, "The filename retrieved from GetFileName by null path " + "must be NULL!"); } catch (Exception err) { Assert.Fail(err.Message); } }
public void Test_GetFileName_NoExisting_FullPath() { try { const string pathAbs = "D:\\GitHub\\software-testing\\MaksGovor.FileWorker.Test\\NoExist.txt"; string received = BaseFileWorker.GetFileName(pathAbs); Assert.IsNull(received, "The filename retrieved from GetFileName by full path " + "must be NULL on a path that does not exist!"); } catch (Exception err) { Assert.Fail(err.Message); } }
public void Test_GetFileName_NoExisting_RelativePath() { try { const string pathRel = ".\\..\\..\\NoExist.txt"; string received = BaseFileWorker.GetFileName(pathRel); Assert.IsNull(received, "The filename retrieved from GetFileName by relative path " + "must be NULL on a path that does not exist!"); } catch (Exception err) { Assert.Fail(err.Message); } }
public void Test_GetFileName_Existing_FullPath() { try { const string pathAbs = "D:\\GitHub\\software-testing\\MaksGovor.FileWorker.Test\\testfile.txt"; string received = BaseFileWorker.GetFileName(pathAbs); const string available = "testfile.txt"; Assert.AreEqual(available, received, "The filename retrieved from GetFileName by full path " + "do not match the available result!"); } catch (Exception err) { Assert.Fail(err.Message); } }
public void Test_GetFileName_Existing_RelativePath() { try { const string pathRel = ".\\..\\..\\testfile.txt"; string received = BaseFileWorker.GetFileName(pathRel); const string available = "testfile.txt"; Assert.AreEqual(available, received, "The filename retrieved from GetFileName by relative path " + "do not match the available result!"); } catch (Exception err) { Assert.Fail(err.Message); } }
public void ReadFileName_ReturnsNull_NonExistFiles(string fileName) { try { File.Delete(fileName); } catch (Exception e) { } var path = $"{CurrentDirectory}\\{fileName}"; Action codeToTest = () => { var res_fileName = BaseFileWorker.GetFileName(fileName); var res_fileNameFromPath = BaseFileWorker.GetFileName(path); Assert.Null(res_fileName); Assert.Null(res_fileNameFromPath); }; var ex = Record.Exception(codeToTest); Assert.Null(ex); }
public void TestGetFileNameReturnValidName() { //without file extension Assert.Equal("IIG", BaseFileWorker.GetFileName(pathToFiles + @"\IIG")); //regular Assert.Equal("a.txt", BaseFileWorker.GetFileName(pathToFiles + @"\a.txt")); //with space in name Assert.Equal("I IG.txt", BaseFileWorker.GetFileName(pathToFiles + @"\I IG.txt")); //with cyrilic in nane Assert.Equal("абв.txt", BaseFileWorker.GetFileName(pathToFiles + @"\абв.txt")); //with ieroglif Assert.Equal("お母様.txt", BaseFileWorker.GetFileName(pathToFiles + @"\お母様.txt")); //with few dots in name Assert.Equal("a.b.c.txt", BaseFileWorker.GetFileName(pathToFiles + @"\a.b.c.txt")); //with smiles Assert.Equal("😅.txt", BaseFileWorker.GetFileName(pathToFiles + @"\😅.txt")); //with different extensions Assert.Equal("a.csc", BaseFileWorker.GetFileName(pathToFiles + @"\a.csc")); Assert.Equal("a.docx", BaseFileWorker.GetFileName(pathToFiles + @"\a.docx")); Assert.Equal("a.mp4", BaseFileWorker.GetFileName(pathToFiles + @"\a.mp4")); Assert.Equal("a.pptx", BaseFileWorker.GetFileName(pathToFiles + @"\a.pptx")); Assert.Equal("a.torrent", BaseFileWorker.GetFileName(pathToFiles + @"\a.torrent")); }
public void GetFileWithoutExtencionName() { Assert.Equal("IIG", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\IIG")); }
public void GetFileNameWithoutPath() { Assert.Null(BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest")); }
public void GetFilenameError(string path) { Assert.Throws <Exception>(() => BaseFileWorker.GetFileName(path)); }
public void GetFilenameNotEqual(string filename, string path) { Directory.CreateDirectory(path); Assert.NotEqual(filename, BaseFileWorker.GetFileName(path)); }
public void Test_GetFileName_Empty_Path() { Assert.IsNull(BaseFileWorker.GetFileName("")); }
public void GetFileName_FileExists_ReturnFileName() { string result = BaseFileWorker.GetFileName(pathToLabFolder + "/somefile.txt"); Assert.AreEqual("somefile.txt", result); }
public void Test_GetFileName_Non_Existent_File() { Assert.IsNull(BaseFileWorker.GetFileName("C:\\TestFiles\\2.txt")); }
public void Test_GetFileName_No_Extension() { Assert.IsNull(BaseFileWorker.GetFileName("C:\\TestFiles\\1")); }
public void GetFilenameEqual(string filename, string path) { File.WriteAllText(path, filename); Assert.Equal(filename, BaseFileWorker.GetFileName(path)); }
public void GetFileWithAltCodesName() { Assert.Equal("☺☻♥♫►.txt", BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\☺☻♥♫►.txt")); }
public void GetFileName_FileDoesNotExist_ReturnNull() { string result = BaseFileWorker.GetFileName(pathToLabFolder + "/somefile2.txt"); Assert.AreEqual(null, result); }
public void GetNotExistingFileName() { Assert.Null(BaseFileWorker.GetFileName("C:\\FileWokerTest\\GetFilesSomethingTest\\void")); }