Ejemplo n.º 1
0
        public void TestCase1()
        {
            var src = new[] { "line1", "line2", "line3" };
            var ver1 = new[] { "line1", "line2", "line3" };
            var ver2 = new[] { "line1", "line2", "line3" };

            var merger = new Merger(src, ver1, ver2);
            var result = merger.Merge();

            Assert.AreEqual("line1", result[0]);
            Assert.AreEqual("line2", result[1]);
            Assert.AreEqual("line3", result[2]);
        }
Ejemplo n.º 2
0
        public void TestCase4()
        {
            var src = new[] { "line1", "line2", "line3" };
            var ver1 = new[] { "line7", "line2", "line3", "line4" };
            var ver2 = new[] { "line1", "line2", "line3", "line5", "line6" };

            var merger = new Merger(src, ver1, ver2);
            var result = merger.Merge();

            Console.WriteLine(string.Join("\n", result));

            Assert.AreEqual("line7", result[0]);
            Assert.AreEqual("line2", result[1]);
            Assert.AreEqual("line3", result[2]);
            Assert.AreEqual("line4", result[3]);
            Assert.AreEqual("line5", result[4]);
            Assert.AreEqual("line6", result[5]);
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Required 4 arguments: <source-file>, <version1-file>, <version2-file>, <output-file>");
                return;
            }

            var sourcePath   = args[0];
            var version1Path = args[1];
            var version2Path = args[2];
            var outputPath   = args[3];

            if (!File.Exists(sourcePath))
            {
                Console.WriteLine($"Source File not found: {sourcePath}");
                return;
            }

            if (!File.Exists(version1Path))
            {
                Console.WriteLine($"Version 1 File not found: {version1Path}");
                return;
            }

            if (!File.Exists(version2Path))
            {
                Console.WriteLine($"Version 2 File not found: {version1Path}");
                return;
            }

            var source   = File.ReadAllLines(sourcePath);
            var version1 = File.ReadAllLines(version1Path);
            var version2 = File.ReadAllLines(version2Path);

            var merger = new Merger(source, version1, version2);

            try {
                merger.Merge(outputPath);
            } catch (IOException e) {
                Console.Error.WriteLine(e.Message);
            }
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            if (args.Length != 4) {
                Console.WriteLine("Required 4 arguments: <source-file>, <version1-file>, <version2-file>, <output-file>");
                return;
            }

            var sourcePath = args[0];
            var version1Path = args[1];
            var version2Path = args[2];
            var outputPath = args[3];

            if (!File.Exists(sourcePath)) {
                Console.WriteLine($"Source File not found: {sourcePath}");
                return;
            }

            if (!File.Exists(version1Path)) {
                Console.WriteLine($"Version 1 File not found: {version1Path}");
                return;
            }

            if (!File.Exists(version2Path)) {
                Console.WriteLine($"Version 2 File not found: {version1Path}");
                return;
            }

            var source = File.ReadAllLines(sourcePath);
            var version1 = File.ReadAllLines(version1Path);
            var version2 = File.ReadAllLines(version2Path);

            var merger = new Merger(source, version1, version2);
            try {
                merger.Merge(outputPath);
            } catch (IOException e) {
                Console.Error.WriteLine(e.Message);
            }
        }
Ejemplo n.º 5
0
        public void TestCase7()
        {
            var src = new[] {
                "{",
                "class Test{",
                "\n",
                "}",
                "}" };
            var ver1 = new[] {
                "{",
                "class Test{",
                "public void Func1(){",
                "}",
                "}",
                "}"
            };
            var ver2 = new[] {
                "{",
                "class Test{",
                "public void Func2(){",
                "}",
                "}",
                "}"
            };

            var merger = new Merger(src, ver1, ver2);
            var result = merger.Merge();

            Console.WriteLine(string.Join("\n", result));

            Assert.AreEqual("{", result[0]);
            Assert.AreEqual("class Test{", result[1]);
            Assert.AreEqual("public void Func1(){", result[2]);
            Assert.AreEqual("}", result[3]);
            Assert.AreEqual("public void Func2(){", result[4]);
            Assert.AreEqual("}", result[5]);
            Assert.AreEqual("}", result[6]);
            Assert.AreEqual("}", result[7]);
        }