public void TestSrcMLWithNoMappingFile() { Assert.IsTrue(File.Exists(@"..\..\TestInputs\function_def.xml")); Assert.IsTrue(File.Exists(@"..\..\TestInputs\method_def.xml")); Assert.IsTrue(File.Exists(@"..\..\TestInputs\nested_scopes.xml")); Assert.IsTrue(Directory.Exists(@"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTest")); try { File.Copy(@"..\..\TestInputs\function_def.xml", @"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTest\function_def.xml", true); Assert.IsTrue(File.Exists(@"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTest\function_def.xml")); File.Copy(@"..\..\TestInputs\method_def.xml", @"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTestmethod_def.xml", true); File.Copy(@"..\..\TestInputs\nested_scopes.xml", @"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTestnested_scopes.xml", true); } catch (Exception e) { Console.WriteLine("EXCEPTION THROWN: {0}", e.Message); } //Currently, SrcMLFileNameMapping sets the source path to null within this function: GetSourcePathFromTargetFile. Until that's fixed, this test won't work. var map = new SrcMLFileNameMapping("mappingTest"); Assert.NotNull(map); Console.WriteLine("PATH: {0}", map.GetSourcePath(@"mappingTest\function_def.xml")); Assert.AreEqual(@"..\..\TestInputs\function_def.cpp", map.GetSourcePath(@"mappingTest\function_def.xml")); Assert.AreEqual(@"..\..\TestInputs\method_def.cpp", map.GetSourcePath(@"mappingTest\method_def.xml")); Assert.AreEqual(@"..\..\TestInputs\nested_scopes.c", map.GetSourcePath(@"mappingTest\nested_scopes.xml")); }
public void TestSrcMLWithNoMappingFile() { File.Copy(@"..\..\TestInputs\function_def.xml", @"mappingTest\function_def.xml", true); File.Copy(@"..\..\TestInputs\method_def.xml", @"mappingTest\method_def.xml", true); File.Copy(@"..\..\TestInputs\nested_scopes.xml", @"mappingTest\nested_scopes.xml", true); var map = new SrcMLFileNameMapping("mappingTest"); Assert.AreEqual(@"C:\Workspaces\SrcML.NET\TestInputs\function_def.cpp", map.GetSourcePath(@"function_def.xml")); Assert.AreEqual(@"C:\Workspaces\SrcML.NET\TestInputs\method_def.cpp", map.GetSourcePath(@"method_def.xml")); Assert.AreEqual(@"C:\Workspaces\SrcML.NET\TestInputs\nested_scopes.c", map.GetSourcePath(@"nested_scopes.xml")); }
public void TestFolderWithXmlNoMappingFile_NonSrcMLXml() { File.Copy(@"..\..\TestInputs\function_def.xml", @"mappingTest\function_def.xml", true); File.Copy(@"..\..\TestInputs\method_def.xml", @"mappingTest\method_def.xml", true); File.Copy(@"..\..\TestInputs\nested_scopes.xml", @"mappingTest\nested_scopes.xml", true); File.Copy(@"..\..\TestInputs\NotSrcML.xml", @"mappingTest\NotSrcML.xml", true); //Currently, SrcMLFileNameMapping sets the source path to null within this function: GetSourcePathFromTargetFile. Until that's fixed, this test won't work. var map = new SrcMLFileNameMapping("mappingTest"); Assert.AreEqual(@"..\..\TestInputs\function_def.cpp", map.GetSourcePath(@"mappingTest\function_def.xml")); Assert.AreEqual(@"..\..\TestInputs\method_def.cpp", map.GetSourcePath(@"mappingTest\method_def.xml")); Assert.AreEqual(@"..\..\TestInputs\nested_scopes.c", map.GetSourcePath(@"mappingTest\nested_scopes.xml")); }
public void TestRountrip() { var map = new SrcMLFileNameMapping("mappingTest"); var xmlPath = map.GetTargetPath("Foo.cs"); Assert.AreEqual(Path.GetFullPath("Foo.cs"), map.GetSourcePath(xmlPath)); }
public void TestXmlPathWithDifferentCase() { var xmlFilePath = @"..\..\TestInputs\function_def.xml"; var sourceFilePath = @"C:\Workspaces\SrcML.NET\TestInputs\function_def.cpp"; File.Copy(xmlFilePath, @"mappingTest\function_def.xml", true); var map = new SrcMLFileNameMapping("mappingTest"); var storedXmlPath = map.GetTargetPath(sourceFilePath); Assert.IsNotNull(map.GetSourcePath(storedXmlPath)); var modifiedDriveLetter = Char.IsLower(storedXmlPath[0]) ? Char.ToUpper(storedXmlPath[0]) : Char.ToLower(storedXmlPath[0]); var absoluteXmlPath = String.Concat(modifiedDriveLetter, storedXmlPath.Substring(1)); Assert.IsNotNull(map.GetSourcePath(absoluteXmlPath)); }
public void TestGetSourcePath_JustFileName() { string fileContents = @"C:\Foo\Bar\test.cs|{0}\mappingTest\test.cs.1.xml C:\Foo\Bar\Example.cs|{0}\mappingTest\Example.cs.1.xml C:\Foo\Bar\xyzzy\Example.cs|{0}\mappingTest\Example.cs.2.xml"; File.WriteAllText(@"mappingTest\mapping.txt", string.Format(fileContents, Environment.CurrentDirectory)); var map = new SrcMLFileNameMapping("mappingTest"); var sourcePath = map.GetSourcePath(@"Example.cs.2.xml"); Assert.AreEqual(@"C:\Foo\Bar\xyzzy\Example.cs", sourcePath); }
public void TestGetSourcePath_FullPath() { string fileContents = @"C:\Foo\Bar\test.cs|C:\srcmlArchive\test.cs.1.xml C:\Foo\Bar\Example.cs|C:\srcmlArchive\Example.cs.1.xml C:\Foo\Bar\xyzzy\Example.cs|C:\srcmlArchive\Example.cs.2.xml"; File.WriteAllText(@"mappingTest\mapping.txt", fileContents); var map = new SrcMLFileNameMapping("mappingTest"); var sourcePath = map.GetSourcePath(@"C:\srcmlArchive\Example.cs.1.xml"); Assert.AreEqual(@"C:\Foo\Bar\Example.cs", sourcePath); }
public void TestXmlPathWithDifferentCase() { var xmlFilePath = @"..\..\TestInputs\function_def.xml"; var sourceFilePath = @"C:\Workspaces\SrcML.NET\TestInputs\function_def.cpp"; File.Copy(xmlFilePath, @"mappingTest\function_def.xml", true); var map = new SrcMLFileNameMapping("mappingTest"); var storedXmlPath = map.GetTargetPath(sourceFilePath); Assert.IsNotNull(map.GetSourcePath(storedXmlPath)); var modifiedDriveLetter = Char.IsLower(storedXmlPath[0]) ? Char.ToUpper(storedXmlPath[0]) : Char.ToLower(storedXmlPath[0]); var absoluteXmlPath = String.Concat(modifiedDriveLetter, storedXmlPath.Substring(1)); Assert.IsNotNull(map.GetSourcePath(absoluteXmlPath)); }
public void TestRountrip() { var map = new SrcMLFileNameMapping("mappingTest"); var xmlPath = map.GetTargetPath("Foo.cs"); Assert.AreEqual(Path.GetFullPath("Foo.cs"), map.GetSourcePath(xmlPath)); }
public void TestGetSourcePath_JustFileName() { string fileContents = @"C:\Foo\Bar\test.cs|{0}\mappingTest\test.cs.1.xml C:\Foo\Bar\Example.cs|{0}\mappingTest\Example.cs.1.xml C:\Foo\Bar\xyzzy\Example.cs|{0}\mappingTest\Example.cs.2.xml"; File.WriteAllText(@"mappingTest\mapping.txt", string.Format(fileContents, Environment.CurrentDirectory)); var map = new SrcMLFileNameMapping("mappingTest"); var sourcePath = map.GetSourcePath(@"Example.cs.2.xml"); Assert.AreEqual(@"C:\Foo\Bar\xyzzy\Example.cs", sourcePath); }
public void TestGetSourcePath_FullPath() { string fileContents = @"C:\Foo\Bar\test.cs|C:\srcmlArchive\test.cs.1.xml C:\Foo\Bar\Example.cs|C:\srcmlArchive\Example.cs.1.xml C:\Foo\Bar\xyzzy\Example.cs|C:\srcmlArchive\Example.cs.2.xml"; File.WriteAllText(@"mappingTest\mapping.txt", fileContents); var map = new SrcMLFileNameMapping("mappingTest"); var sourcePath = map.GetSourcePath(@"C:\srcmlArchive\Example.cs.1.xml"); Assert.AreEqual(@"C:\Foo\Bar\Example.cs", sourcePath); }
public void TestFolderWithXmlNoMappingFile_NonSrcMLXml() { File.Copy(@"..\..\TestInputs\function_def.xml", @"mappingTest\function_def.xml", true); File.Copy(@"..\..\TestInputs\method_def.xml", @"mappingTest\method_def.xml", true); File.Copy(@"..\..\TestInputs\nested_scopes.xml", @"mappingTest\nested_scopes.xml", true); File.Copy(@"..\..\TestInputs\NotSrcML.xml", @"mappingTest\NotSrcML.xml", true); //Currently, SrcMLFileNameMapping sets the source path to null within this function: GetSourcePathFromTargetFile. Until that's fixed, this test won't work. var map = new SrcMLFileNameMapping("mappingTest"); Assert.AreEqual(@"..\..\TestInputs\function_def.cpp", map.GetSourcePath(@"mappingTest\function_def.xml")); Assert.AreEqual(@"..\..\TestInputs\method_def.cpp", map.GetSourcePath(@"mappingTest\method_def.xml")); Assert.AreEqual(@"..\..\TestInputs\nested_scopes.c", map.GetSourcePath(@"mappingTest\nested_scopes.xml")); }
public void TestSrcMLWithNoMappingFile() { Assert.IsTrue(File.Exists(@"..\..\TestInputs\function_def.xml")); Assert.IsTrue(File.Exists(@"..\..\TestInputs\method_def.xml")); Assert.IsTrue(File.Exists(@"..\..\TestInputs\nested_scopes.xml")); Assert.IsTrue(Directory.Exists(@"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTest")); try { File.Copy(@"..\..\TestInputs\function_def.xml", @"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTest\function_def.xml", true); Assert.IsTrue(File.Exists(@"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTest\function_def.xml")); File.Copy(@"..\..\TestInputs\method_def.xml", @"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTestmethod_def.xml", true); File.Copy(@"..\..\TestInputs\nested_scopes.xml", @"C:\Users\Christian\Documents\SrcML.NET\Build\Debug\mappingTestnested_scopes.xml", true); } catch (Exception e) { Console.WriteLine("EXCEPTION THROWN: {0}", e.Message); } //Currently, SrcMLFileNameMapping sets the source path to null within this function: GetSourcePathFromTargetFile. Until that's fixed, this test won't work. var map = new SrcMLFileNameMapping("mappingTest"); Assert.NotNull(map); Console.WriteLine("PATH: {0}", map.GetSourcePath(@"mappingTest\function_def.xml")); Assert.AreEqual(@"..\..\TestInputs\function_def.cpp", map.GetSourcePath(@"mappingTest\function_def.xml")); Assert.AreEqual(@"..\..\TestInputs\method_def.cpp", map.GetSourcePath(@"mappingTest\method_def.xml")); Assert.AreEqual(@"..\..\TestInputs\nested_scopes.c", map.GetSourcePath(@"mappingTest\nested_scopes.xml")); }
public void TestFolderWithXmlNoMappingFile_NonSrcMLXml() { File.Copy(@"..\..\TestInputs\function_def.xml", @"mappingTest\function_def.xml", true); File.Copy(@"..\..\TestInputs\method_def.xml", @"mappingTest\method_def.xml", true); File.Copy(@"..\..\TestInputs\nested_scopes.xml", @"mappingTest\nested_scopes.xml", true); File.Copy(@"..\..\TestInputs\NotSrcML.xml", @"mappingTest\NotSrcML.xml", true); var map = new SrcMLFileNameMapping("mappingTest"); Assert.AreEqual(@"C:\Workspaces\SrcML.NET\TestInputs\function_def.cpp", map.GetSourcePath(@"function_def.xml")); Assert.AreEqual(@"C:\Workspaces\SrcML.NET\TestInputs\method_def.cpp", map.GetSourcePath(@"method_def.xml")); Assert.AreEqual(@"C:\Workspaces\SrcML.NET\TestInputs\nested_scopes.c", map.GetSourcePath(@"nested_scopes.xml")); }