static void Main() { // Run tests: /* * Tests mTestObject = new Tests(); * mTestObject.RunTests(); * Console.ReadLine(); // This line is here so we can see the result in the console when operating from VS */ // Run user console interface: string sourceDirPath, auxDirPath, destDirPath, minNumForSimilarityStr; int minNumForSimilarity; do { Console.WriteLine("Please enter a valid full source directory path:"); sourceDirPath = Console.ReadLine(); } while (!Directory.Exists(sourceDirPath)); do { Console.WriteLine("Please enter valid full auxillery directory path:"); auxDirPath = Console.ReadLine(); } while (!Directory.Exists(auxDirPath)); Console.WriteLine("Please enter full destination directory path:"); destDirPath = Console.ReadLine(); // We don't need to check destination since it will be created if it doesn't exist do { Console.WriteLine("Please enter a number between 0 and 100,000 for minimal identical numbers to be counted as similarity:"); minNumForSimilarityStr = Console.ReadLine(); } while (!int.TryParse(minNumForSimilarityStr, out minNumForSimilarity) || minNumForSimilarity < 0 || minNumForSimilarity > 100000); Console.WriteLine("Running..."); IntegersSetCsvManager manager = new IntegersSetCsvManager(); try { manager.CopySimilarCsvs(sourceDirPath, auxDirPath, destDirPath, minNumForSimilarity); } catch (Exception) { Console.WriteLine("Unknown error occured"); } Console.WriteLine("Finished. Check destination folder for results. Press enter to exit."); Console.ReadLine(); // This line is here so we can see the result in the console when operating from VS }
private bool invalidInputTest(int iTestsCount) { IntegersSetCsvManager manager = new IntegersSetCsvManager(); string sourceDirPath = Path.Combine(Directory.GetCurrentDirectory(), "src" + (iTestsCount - 1)); // Exists from previous test string auxDirPath = Path.Combine(Directory.GetCurrentDirectory(), "aux" + iTestsCount); // Doesn't Exist string destDirPath = Path.Combine(Directory.GetCurrentDirectory(), "aux" + iTestsCount); // Shouldn't be created manager.CopySimilarCsvs(sourceDirPath, auxDirPath, destDirPath, 2); if (!Directory.Exists(destDirPath)) { return(true); } else { return(false); } }
private bool differentSrcAndAuxTest(int iTestsCount, bool iEraseFilesAtTestEnd = false) { bool testRes = false; // Create Source Dir string sourceDirPath = Path.Combine(Directory.GetCurrentDirectory(), "src" + iTestsCount); string[] sourceContents = { "", "8", "1,7", "1,2,3", "1,2,4,8" }; createCsvDir(sourceDirPath, sourceContents); // Create Aux Dir string auxDirPath = Path.Combine(Directory.GetCurrentDirectory(), "aux" + iTestsCount); string[] auxContents = { "", "1", "1,2", "1,2,3", "1,2,3,4" }; createCsvDir(auxDirPath, auxContents); // Test IntegersSetCsvManager manager = new IntegersSetCsvManager(); string destDirPath = Path.Combine(Directory.GetCurrentDirectory(), "dest" + iTestsCount); manager.CopySimilarCsvs(sourceDirPath, auxDirPath, destDirPath, 2); if (Directory.GetFiles(destDirPath).Length == 3) { testRes = true; } if (iEraseFilesAtTestEnd) { // Erase Created Directories recursivly Directory.Delete(sourceDirPath, true); Directory.Delete(auxDirPath, true); if (Directory.Exists(destDirPath)) { Directory.Delete(destDirPath, true); } } return(testRes); }