Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/Extras/CSharpBinding/Test/Test.cs')
-rw-r--r--main/Extras/CSharpBinding/Test/Test.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/main/Extras/CSharpBinding/Test/Test.cs b/main/Extras/CSharpBinding/Test/Test.cs
new file mode 100644
index 0000000000..b67e69e86f
--- /dev/null
+++ b/main/Extras/CSharpBinding/Test/Test.cs
@@ -0,0 +1,67 @@
+using System;
+using System.IO;
+
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using MonoDevelop.Projects.Parser;
+using MonoDevelop.Ide.Gui;
+
+using NUnit.Framework;
+
+namespace CSharpBinding.Test
+{
+ [TestFixture]
+ public class ResolverTest
+ {
+ string testFileName = "Test.cs";
+ string testFileContents = @"
+using System;
+using System.IO;
+
+public class C
+{
+ public static void Main()
+ {
+ }
+}
+";
+ private IParserContext parserContext;
+
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ Runtime.Initialize();
+ AddinManager.PreloadAddin(null, "MonoDevelop.Projects");
+
+ TextWriter tw = new StreamWriter(testFileName);
+ tw.Write(testFileContents);
+ tw.Close();
+
+ IParserDatabase pdb = Services.ParserService.CreateParserDatabase();
+ parserContext = pdb.GetFileParserContext(testFileName);
+ parserContext.ParseFile(testFileName, testFileContents);
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ File.Delete(testFileName);
+ }
+
+ [Test]
+ public void ResolveNamespace()
+ {
+ ILanguageItem languageItem = parserContext.ResolveIdentifier("System", 1, 9, testFileName, testFileContents);
+ Assert.IsTrue(languageItem is Namespace);
+ Assert.AreEqual("System", (languageItem as Namespace).Name);
+
+ languageItem = parserContext.ResolveIdentifier("System.IO", 2, 14, testFileName, testFileContents);
+ Assert.IsTrue(languageItem is Namespace);
+ Assert.AreEqual("System.IO", (languageItem as Namespace).Name);
+ }
+ }
+}
+
+
+
+