Esempio n. 1
0
        public static bool Test2_1()
        {
            string tempDir  = Path.GetTempPath();
            string testPath = Path.Combine(tempDir, "tests/");

            Directory.CreateDirectory(tempDir);
            CreateEmptyFile(testPath + "modest.h");
            CreateEmptyFile(testPath + "modest.cpp");
            CreateEmptyFile(testPath + "modest.txt");

            RepeatingFilesRemover remover = new RepeatingFilesRemover();
            int  result       = remover.RemoveRepeatingFiles(testPath, ".cpp");
            bool firstRemoved = !RepeatingFilesRemover.FileExist(testPath + "modest.h");
            bool thirdRemoved = !RepeatingFilesRemover.FileExist(testPath + "modest.txt");

            RemoveDirs(testPath);
            return(result == 2 && firstRemoved && thirdRemoved);
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     if (args.Length > 0 && args[0] == "--help")
     {
         Console.WriteLine("Usage: ./DotNetCore [-t] [path] [ext] [--tests]");
         Console.WriteLine("       [-t] - type, find-oldest-dir or delete-repeats");
         Console.WriteLine("       [path] - path to the directory");
         Console.WriteLine("       [ext] - extension of allowed files when delete-repeats");
         Console.WriteLine("       [--tests] - run tests for both functionalities find-oldest-dir and delete-repeats");
     }
     else if (args.Length > 0 && args[0] == "--tests")
     {
         RunFirstTaskTests();
         RunSecondTaskTests();
     }
     else if (args.Length > 2 && args[0] == "-t")
     {
         if (args[1] == "find-oldest-dir")
         {
             string directory = args[2];
             OldestFolderSearcher searcher = new OldestFolderSearcher();
             string oldestDir = searcher.FindOldestDir(directory);
             Console.WriteLine("Oldest dir: " + oldestDir);
         }
         else if (args[1] == "delete-repeats" && args.Length > 3)
         {
             string directory              = args[2];
             string allowedExt             = args[3];
             RepeatingFilesRemover remover = new RepeatingFilesRemover();
             int removedCount              = remover.RemoveRepeatingFiles(directory, allowedExt);
             Console.WriteLine("Removed: " + removedCount + " files\n");
         }
     }
     else
     {
         Console.WriteLine("Wrong parameter use --help");
     }
 }