예제 #1
0
        private void RunCase(string case_name, string input_name, string output_name, uint n)
        {
            var root_directory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent;
            var input_file     = Path.Combine(root_directory.FullName, "Cases", case_name, input_name);
            var output_file    = Path.Combine(root_directory.FullName, "Cases", case_name, output_name);

            TextFileRepeater.CreateFile(input_file, output_file, n);
        }
        public void ZeroRepetitions()
        {
            // Arrange
            var lines = new string[] { "Line1", "Line2", "Line3" };

            // Act
            var result = TextFileRepeater.RepeatLines(lines, 0);

            // Assert
            Assert.AreEqual(0, result.Count);
        }
예제 #3
0
        static void Main(string[] args)
        {
            // Using the CommandLineParser with the custom "Options" class defined above
            // in order to simplify parsing input arguements.
            Parser.Default.ParseArguments <Options>(args).WithParsed(o =>
            {
                string input_file_path  = Path.GetFullPath(o.InputFilePath);
                string output_file_path = Path.GetFullPath(o.OutputFilePath);

                if (!File.Exists(input_file_path))
                {
                    Console.WriteLine($"ERROR: Input file {input_file_path} does not exist");
                    Environment.Exit(1);
                }

                Console.WriteLine($"Copying lines {o.Repetitions} times from {o.InputFilePath} to {o.OutputFilePath}");
                TextFileRepeater.CreateFile(input_file_path, output_file_path, o.Repetitions);
                Console.WriteLine($"Success!");
            });
        }