public void MultipleFilesTest_Language()
        {
            var srcmlObject = new Src2SrcMLRunner(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation));
            var doc         = srcmlObject.GenerateSrcMLFromFiles(new string[] { "srcmltest\\foo.c", "srcmltest\\bar.c" }, "srcml_xml\\multiplefile.xml", Language.CPlusPlus);

            Assert.IsNotNull(doc);
            var files = doc.FileUnits.ToList();

            Assert.AreEqual(2, files.Count());
            string file = "srcmltest\\foo.c";
            var    f1   = (from ele in files
                           where ele.Attribute("filename").Value == file
                           select ele);

            Assert.AreEqual("srcmltest\\foo.c", f1.FirstOrDefault().Attribute("filename").Value);
            Assert.AreEqual("C++", f1.FirstOrDefault().Attribute("language").Value);

            string file2 = "srcmltest\\bar.c";
            var    f2    = (from ele in files
                            where ele.Attribute("filename").Value == file2
                            select ele);

            Assert.AreEqual("srcmltest\\bar.c", f2.FirstOrDefault().Attribute("filename").Value);
            Assert.AreEqual("C++", f2.FirstOrDefault().Attribute("language").Value);
        }
        public void MultipleFilesTest_DifferentDirectories()
        {
            var srcmlObject = new Src2SrcMLRunner(Path.Combine(SrcMLHelper.GetSrcMLRootDirectory(), SrcMLHelper.srcMLExecutableLocation));
            var doc         = srcmlObject.GenerateSrcMLFromFiles(new string[] { "srcmltest\\foo.c", "srcmltest\\bar.c", "..\\..\\TestInputs\\baz.cpp" }, "srcml_xml\\multiplefile.xml");

            Assert.IsNotNull(doc);
            var files = doc.FileUnits.ToList();

            Assert.AreEqual(3, files.Count());

            string file = "srcmltest\\foo.c";
            var    f1   = (from ele in files
                           where ele.Attribute("filename").Value == file
                           select ele);

            Assert.AreEqual("srcmltest\\foo.c", f1.FirstOrDefault().Attribute("filename").Value);

            string file1 = "srcmltest\\bar.c";
            var    f2    = (from ele in files
                            where ele.Attribute("filename").Value == file1
                            select ele);

            Assert.AreEqual("srcmltest\\bar.c", f2.FirstOrDefault().Attribute("filename").Value);

            string file2 = "\\..\\TestInputs\\baz.cpp";
            var    f3    = (from ele in files
                            where ele.Attribute("filename").Value == file2
                            select ele);

            Console.WriteLine(f3.FirstOrDefault().Value);
            Assert.AreEqual("\\..\\TestInputs\\baz.cpp", f3.FirstOrDefault().Attribute("filename").Value);
        }
        public void MultipleFilesTest()
        {
            var srcmlObject = new Src2SrcMLRunner(Path.Combine(".", "SrcML"));
            var doc         = srcmlObject.GenerateSrcMLFromFiles(new string[] { "srcmltest\\foo.c", "srcmltest\\bar.c" }, "srcml_xml\\multiplefile.xml");

            Assert.IsNotNull(doc);
            var files = doc.FileUnits.ToList();

            Assert.AreEqual(2, files.Count());
            Assert.AreEqual("srcmltest\\foo.c", files[0].Attribute("filename").Value);
            Assert.AreEqual("srcmltest\\bar.c", files[1].Attribute("filename").Value);
        }
Beispiel #4
0
        public void MultipleFilesTest_DifferentDirectories()
        {
            var srcmlObject = new Src2SrcMLRunner();
            var doc         = srcmlObject.GenerateSrcMLFromFiles(new string[] { "srcmltest\\foo.c", "srcmltest\\bar.c", "..\\..\\TestInputs\\baz.cpp" }, "srcml_xml\\multiplefile.xml");

            Assert.IsNotNull(doc);
            var files = doc.FileUnits.ToList();

            Assert.AreEqual(3, files.Count());
            Assert.AreEqual("srcmltest\\foo.c", files[0].Attribute("filename").Value);
            Assert.AreEqual("srcmltest\\bar.c", files[1].Attribute("filename").Value);
            Assert.AreEqual("TestInputs\\baz.cpp", files[2].Attribute("filename").Value);
        }