示例#1
0
        public void ShouldSortGeneratedFile(string fileSize, string sortArguments = null)
        {
            var inputFileName    = Path.Combine("Content", fileSize + ".txt");
            var outputFileName   = Path.Combine("Content", fileSize + "_sorted.txt");
            var expectedFileSize = MemorySize.Parse(fileSize);

            var generateProcess = ProcessRunner.RunProcess("FileGenerate.exe", $"{inputFileName} -s {fileSize}");

            ProcessAssert.HasZeroExitCode(generateProcess, $"File '{inputFileName}' generation failed.");
            inputFileName  = Path.Combine(generateProcess.StartInfo.WorkingDirectory, inputFileName);
            outputFileName = Path.Combine(generateProcess.StartInfo.WorkingDirectory, outputFileName);
            Console.WriteLine($"File '{inputFileName}' was generated in {generateProcess.TotalProcessorTime}.");

            var sortProcess = ProcessRunner.RunProcess("FileSort.exe", $"{inputFileName} {outputFileName} {sortArguments}");

            ProcessAssert.HasZeroExitCode(sortProcess, $"File '{inputFileName}' sort failed.");
            Console.WriteLine($"File '{outputFileName}' was sorted in {sortProcess.TotalProcessorTime}.");
            FileSizeAssert.HasSize(outputFileName, expectedFileSize);

            var checkProcess = ProcessRunner.RunProcess("FileCheck.exe", $"{outputFileName}");

            Console.WriteLine($"File '{outputFileName}' was checked in {checkProcess.TotalProcessorTime}.");
            ProcessAssert.HasZeroExitCode(checkProcess, $"File '{inputFileName}' was not properly sorted or check failed.");

            //File.Delete(inputFileName);
            //Console.WriteLine($"File '{inputFileName}' was deleted from target directory");
            File.Delete(outputFileName);
            Console.WriteLine($"File '{outputFileName}' was deleted from target directory");
        }
示例#2
0
        public void ShouldGenerateRandomFile(string fileSize)
        {
            var fileName        = Path.Combine("Content", fileSize + ".txt");
            var generateProcess = ProcessRunner.RunProcess("FileGenerate.exe", $"{fileName} -s {fileSize}");

            ProcessAssert.HasZeroExitCode(generateProcess, $"File '{fileName}' generation failed.");
            fileName = Path.Combine(generateProcess.StartInfo.WorkingDirectory, fileName);
            Console.WriteLine($"File '{fileName}' was generated in {generateProcess.TotalProcessorTime}.");
            var expectedFileSize = MemorySize.Parse(fileSize);

            FileSizeAssert.HasSize(fileName, expectedFileSize);

            var checkProcess = ProcessRunner.RunProcess("FileCheck.exe", $"{fileName} --check-format");

            Console.WriteLine($"File '{fileName}' was checked in {checkProcess.TotalProcessorTime}.");
            ProcessAssert.HasZeroExitCode(checkProcess, $"File '{fileName}' was not properly sorted or check failed.");
        }