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/tests/UnitTests/MonoDevelop.Projects')
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/CompletionDatabaseTests.cs889
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/DomCompilationUnitTests.cs133
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/DomPersistenceTests.cs457
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/DomTests.cs228
-rw-r--r--main/tests/UnitTests/MonoDevelop.Projects/SolutionTests.cs2
5 files changed, 1 insertions, 1708 deletions
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/CompletionDatabaseTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/CompletionDatabaseTests.cs
deleted file mode 100644
index 228a8b8a23..0000000000
--- a/main/tests/UnitTests/MonoDevelop.Projects/CompletionDatabaseTests.cs
+++ /dev/null
@@ -1,889 +0,0 @@
-// CompletionDatabaseTests.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-//
-
-using System;
-using System.IO;
-using System.Collections.Generic;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using NUnit.Framework;
-using UnitTests;
-using Mono.CSharp;
-using System.Linq;
-
-namespace MonoDevelop.Projects
-{
- [TestFixture]
- public class CompletionDatabaseTests: TestBase
- {
- Solution solution;
- ProjectDom mainProject;
- ProjectDom lib1;
- ProjectDom lib2;
-
- public override void Setup ()
- {
- base.Setup ();
- string solFile = Util.GetSampleProject ("completion-db-test", "CompletionDbTest.sln");
- solution = (Solution) Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
- ProjectDomService.Load (solution);
-
- Project prj;
- prj = solution.FindProjectByName ("Library2");
- lib2 = ProjectDomService.GetProjectDom (prj);
- lib2.ForceUpdate (true);
- prj = solution.FindProjectByName ("Library1");
- lib1 = ProjectDomService.GetProjectDom (prj);
- lib1.ForceUpdate (true);
- prj = solution.FindProjectByName ("CompletionDbTest");
- mainProject = ProjectDomService.GetProjectDom (prj);
- mainProject.ForceUpdate (true);
- }
-
- public override void TearDown ()
- {
- ProjectDomService.Unload (solution);
- base.TearDown ();
- }
-
- void ReplaceFile (string targetRelativePath, string sourceRelativePath)
- {
- string tfile = mainProject.Project.GetAbsoluteChildPath (targetRelativePath);
- string sfile = mainProject.Project.GetAbsoluteChildPath (sourceRelativePath);
- File.Copy (sfile, tfile, true);
- ProjectDomService.Parse (tfile, null);
- }
-
- [Test]
- public void References ()
- {
- Assert.AreEqual (4, mainProject.References.Count);
- Assert.AreEqual (3, lib1.References.Count);
- Assert.AreEqual (3, lib2.References.Count);
- }
-
- [Test]
- public void SimpleGetType ()
- {
- // Simple get
- IType type = mainProject.GetType ("CompletionDbTest.MainClass");
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.MainClass", type.FullName);
-
- // Deep search in local project
- type = mainProject.GetType ("CompletionDbTest.MainClass", true);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.MainClass", type.FullName);
-
- // Non deep search
- // FIXME: deep search is currently the same as non-deep-search
-// type = mainProject.GetType ("Library2.CWidget", false);
-// Assert.IsNull (type);
-
- // Deep search by default
- type = mainProject.GetType ("Library2.CWidget");
- Assert.IsNotNull (type);
- Assert.AreEqual ("Library2.CWidget", type.FullName);
-
- //check that references are accessible, but not references of references
- type = mainProject.GetType ("Library3.Lib3Class");
- Assert.IsNull (type);
- type = lib2.GetType ("Library3.Lib3Class");
- Assert.IsNotNull (type);
-
- // Deep insensitive
- type = mainProject.GetType ("library2.cwidget", true, false);
- Assert.IsNotNull (type);
- Assert.AreEqual ("Library2.CWidget", type.FullName);
-
- // Case sensitive
- type = mainProject.GetType ("library2.cwidget", true, true);
- Assert.IsNull (type);
-
- // Not generic
- type = mainProject.GetType ("CompletionDbTest.MainClass", 1, true);
- Assert.IsNull (type);
-
- // System.Object
- type = mainProject.GetType ("System.Object", true, true);
- Assert.IsNotNull (type);
- Assert.AreEqual ("System.Object", type.FullName);
- }
-
- [Test]
- public void GetGenericType ()
- {
- List<IReturnType> args = new List<IReturnType> ();
- DomReturnType rt = new DomReturnType ("System.String");
- args.Add (rt);
- IType type = mainProject.GetType ("CompletionDbTest.SomeGeneric", args);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.SomeGeneric[System.String]", type.FullName);
- Assert.AreEqual (0, type.TypeParameters.Count);
-
- IMethod met = FindMember (type, "Run") as IMethod;
- Assert.IsNotNull (met);
- Assert.AreEqual (1, met.Parameters.Count);
- Assert.AreEqual ("System.String", met.Parameters[0].ReturnType.FullName);
- Assert.IsNotNull (met.ReturnType);
- Assert.AreEqual ("System.String", met.ReturnType.FullName);
-
- type = mainProject.GetType ("Library2.GenericWidget");
- Assert.IsNotNull (type);
- Assert.AreEqual ("Library2.GenericWidget", type.FullName);
- Assert.AreEqual (0, type.TypeParameters.Count);
-
- type = mainProject.GetType ("Library2.GenericWidget", 1, true);
- Assert.IsNotNull (type);
- Assert.AreEqual ("Library2.GenericWidget", type.FullName);
- Assert.AreEqual (1, type.TypeParameters.Count);
-
- type = mainProject.GetType ("Library2.GenericWidget", 2, true);
- Assert.IsNotNull (type);
- Assert.AreEqual ("Library2.GenericWidget", type.FullName);
- Assert.AreEqual (2, type.TypeParameters.Count);
-
- type = mainProject.GetType ("Library2.GenericWidget", 3, true);
- Assert.IsNull (type);
-
- // Inner generic type
-
- type = mainProject.GetType ("Library2.Container.InnerClass1", 1, true);
- Assert.IsNotNull (type);
- }
-
- IMember FindMember (IType type, string name)
- {
- foreach (IMember mem in type.Members)
- if (mem.Name == name)
- return mem;
- return null;
- }
-
- [Test]
- public void GetSubclasses ()
- {
- IType type = mainProject.GetType ("Library2.CWidget", true);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("Library2.CContainer"));
- Assert.IsTrue (types.Contains ("Library2.SomeContainer.CInnerWidget"));
- Assert.IsTrue (types.Contains ("Library2.CExtraContainer"));
- Assert.IsTrue (types.Contains ("Library2.SomeContainer.CExtraInnerWidget"));
- Assert.IsTrue (types.Contains ("Library1.CBin"));
- Assert.IsTrue (types.Contains ("Library1.CList"));
- Assert.IsTrue (types.Contains ("Library1.SomeContainer.CInnerWidget"));
- Assert.IsTrue (types.Contains ("Library1.SomeContainer.SomeInnerContainer.CSubInnerWidget"));
- Assert.IsTrue (types.Contains ("Library1.CExtraBin"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerSub"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub.CInnerWidget1"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub.CInnerWidget2"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub.CInnerWidget3"));
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget1"));
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget2"));
- Assert.AreEqual (16, types.Count);
-
- // No deep search
-
- type = mainProject.GetType ("Library2.CWidget", true);
- Assert.IsNotNull (type);
-
- types.Clear ();
- foreach (IType t in mainProject.GetSubclasses (type, false))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget1"));
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget2"));
- Assert.AreEqual (2, types.Count);
-
- // Interface subclassing
-
- type = mainProject.GetType ("Library2.IObject", true);
- Assert.IsNotNull (type);
-
- types.Clear ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("Library2.CExtraContainer"));
- Assert.IsTrue (types.Contains ("Library2.SomeContainer.CExtraInnerWidget"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub.CInnerWidget1"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub.CInnerWidget2"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerSub"));
- Assert.IsTrue (types.Contains ("Library1.ISimple"));
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget1"));
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget2"));
- Assert.AreEqual (9, types.Count);
- }
-
- [Test]
- public void GetFileTypes ()
- {
- string file = lib1.Project.GetAbsoluteChildPath ("MyClass.cs");
-
- List<string> types = new List<string> ();
- foreach (IType t in lib1.GetTypes (file))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("Library1.CBin"));
- Assert.IsTrue (types.Contains ("Library1.CList"));
- Assert.IsTrue (types.Contains ("Library1.SomeContainer"));
- Assert.IsTrue (types.Contains ("Library1.CExtraBin"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerSub"));
- Assert.IsTrue (types.Contains ("Library1.CExtraContainerInnerSub"));
- Assert.IsTrue (types.Contains ("Library1.ISimple"));
- Assert.IsTrue (types.Contains ("Library1.TestAttribute"));
-
- Assert.AreEqual (8, types.Count);
- }
-
- [Test]
- public void GetInheritanceTree ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.CustomWidget1", false);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (type))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget1"));
- Assert.IsTrue (types.Contains ("Library1.CBin"));
- Assert.IsTrue (types.Contains ("Library1.ISimple"));
- Assert.IsTrue (types.Contains ("Library2.CWidget"));
- Assert.IsTrue (types.Contains ("Library2.IObject"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (6, types.Count);
-
- type = mainProject.GetType ("CompletionDbTest.CustomWidget2", false);
-
- types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (type))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.CustomWidget2"));
- Assert.IsTrue (types.Contains ("Library1.SomeContainer.CInnerWidget"));
- Assert.IsTrue (types.Contains ("Library2.IObject"));
- Assert.IsTrue (types.Contains ("Library2.CWidget"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (5, types.Count);
- }
-
-
- [Test]
- public void GetInheritanceTreeForEnumsAndStructs ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.TestEnum", false);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (type)) {
- Console.WriteLine (t.FullName);
- types.Add (t.FullName);
- }
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.TestEnum"));
- Assert.IsTrue (types.Contains ("System.Enum"));
- Assert.IsTrue (types.Contains ("System.Object"));
-
- type = mainProject.GetType ("CompletionDbTest.TestStruct", false);
-
- types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (type))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.TestStruct"));
- Assert.IsTrue (types.Contains ("System.ValueType"));
- Assert.IsTrue (types.Contains ("System.Object"));
- }
- [Test]
- public void GetNamespaceContents ()
- {
- var types = new List<string> ();
- foreach (IMember mem in mainProject.GetNamespaceContents ("SharedNamespace1", true, true))
- types.Add (mem.FullName);
- Assert.IsTrue (types.Contains ("SharedNamespace1.A"));
- Assert.IsTrue (types.Contains ("SharedNamespace1.B"));
- Assert.IsTrue (types.Contains ("SharedNamespace1.E"));
- Assert.IsTrue (types.Contains ("SharedNamespace1.F"));
- Assert.AreEqual (4, types.Count);
-
- types = new List<string> ();
- foreach (IMember mem in mainProject.GetNamespaceContents ("SharedNamespace1", false, true))
- types.Add (mem.FullName);
- Assert.IsTrue (types.Contains ("SharedNamespace1.A"));
- Assert.IsTrue (types.Contains ("SharedNamespace1.B"));
- Assert.AreEqual (2, types.Count);
-
- types = new List<string> ();
- foreach (IMember mem in mainProject.GetNamespaceContents ("sharednamespace1", true, false))
- types.Add (mem.FullName);
- Assert.IsTrue (types.Contains ("SharedNamespace1.A"));
- Assert.IsTrue (types.Contains ("SharedNamespace1.B"));
- Assert.IsTrue (types.Contains ("SharedNamespace1.E"));
- Assert.IsTrue (types.Contains ("SharedNamespace1.F"));
- Assert.AreEqual (4, types.Count);
-
- types = new List<string> ();
- foreach (IMember mem in mainProject.GetNamespaceContents ("SharedNamespace2", true, true))
- types.Add (mem.FullName);
- Assert.IsTrue (types.Contains ("SharedNamespace2.C"));
- Assert.IsTrue (types.Contains ("SharedNamespace2.D"));
- Assert.IsTrue (types.Contains ("SharedNamespace2.G"));
- Assert.IsTrue (types.Contains ("SharedNamespace2.H"));
- Assert.AreEqual (4, types.Count);
-
- types = new List<string> ();
- foreach (IMember mem in mainProject.GetNamespaceContents ("SharedNamespace2", false, true))
- types.Add (mem.FullName);
- Assert.AreEqual (0, types.Count);
- }
-
- [Test]
- public void GetGenericSubclassesNoParams ()
- {
- IType type = mainProject.GetType ("Library2.GenericWidget", true);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (GetName(t));
-
- Assert.IsTrue (types.Contains ("Library2.GenericBin"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBin"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidget"));
- Assert.AreEqual (3, types.Count);
- }
-
- [Test]
- public void GetGenericSubclassesTemplate ()
- {
- // Uninstantiated generic type with one parameter
-
- IType type = mainProject.GetType ("Library2.GenericWidget", 1, true);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (GetName (t));
-
- // We don't support getting the subclasses of a parametrized type.
- // It is not clear what should be considered a subclass in this case.
- Assert.AreEqual (0, types.Count);
- }
-
- [Test]
- public void GetGenericSubclassesParamsInt ()
- {
- // Generic type with one parameter
-
- List<IReturnType> args = new List<IReturnType> ();
- args.Add (new DomReturnType ("System.Int32"));
-
- IType type = mainProject.GetType ("Library2.GenericWidget", args);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (GetName(t));
-
- Assert.IsTrue (types.Contains ("Library2.GenericBin[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library2.GenericBinInt"));
- Assert.IsTrue (types.Contains ("Library2.Container.InnerClass1[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library2.Container.InnerClass2"));
- Assert.IsTrue (types.Contains ("Library2.Container.InnerClass3"));
- Assert.IsTrue (types.Contains ("Library2.Container.InnerClass4"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidget[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBin[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBinInt1"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBinInt2"));
- Assert.IsTrue (types.Contains ("Library1.SubInnerClass[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library1.SubContainer.InnerClass1[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library1.SubContainer.InnerClass2"));
- Assert.IsTrue (types.Contains ("Library1.SubContainer.InnerClass3"));
- Assert.IsTrue (types.Contains ("Library1.SubContainer.InnerClass4"));
- Assert.AreEqual (15, types.Count);
- }
-
- [Test]
- public void GetGenericSubclassesParamsString ()
- {
- // Generic type with one string parameter
-
- List<IReturnType> args = new List<IReturnType> ();
- args.Add (new DomReturnType ("System.String"));
-
- IType type = mainProject.GetType ("Library2.GenericWidget", args);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (GetName(t));
-
- Assert.IsTrue (types.Contains ("Library2.GenericBin[System.String]"));
- Assert.IsTrue (types.Contains ("Library2.GenericBinString"));
- Assert.IsTrue (types.Contains ("Library2.Container.InnerClass1[System.String]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidget[System.String]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBin[System.String]"));
- Assert.IsTrue (types.Contains ("Library1.SubInnerClass[System.String]"));
- Assert.IsTrue (types.Contains ("Library1.SubContainer.InnerClass1[System.String]"));
- Assert.AreEqual (7, types.Count);
- }
-
- [Test]
- public void GetGenericSubclassesParamsStringInt ()
- {
- // Generic type with one string and one int
-
- List<IReturnType> args = new List<IReturnType> ();
- args.Add (new DomReturnType ("System.String"));
- args.Add (new DomReturnType ("System.Int32"));
-
- IType type = mainProject.GetType ("Library2.GenericWidget", args);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (GetName(t));
-
- Assert.IsTrue (types.Contains ("Library2.GenericBin[System.String,System.Int32]"));
- Assert.IsTrue (types.Contains ("Library2.SpecialGenericBin[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library2.GenericBinStringInt"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBin[System.String,System.Int32]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidget[System.String,System.Int32]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBinStringInt1"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBinStringInt2"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidgetStringNull[System.Int32]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidgetNullInt[System.String]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidgetSwapped[System.Int32,System.String]"));
- Assert.AreEqual (10, types.Count);
- }
-
- [Test]
- public void GetGenericSubclassesParamsIntString ()
- {
- // Generic type with one int and one string
-
- List<IReturnType> args = new List<IReturnType> ();
- args.Add (new DomReturnType ("System.Int32"));
- args.Add (new DomReturnType ("System.String"));
-
- IType type = mainProject.GetType ("Library2.GenericWidget", args);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (GetName(t));
-
- Assert.IsTrue (types.Contains ("Library2.GenericBin[System.Int32,System.String]"));
- Assert.IsTrue (types.Contains ("Library2.GenericBinIntString"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericBin[System.Int32,System.String]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidget[System.Int32,System.String]"));
- Assert.IsTrue (types.Contains ("Library1.SubGenericWidgetSwapped[System.String,System.Int32]"));
- Assert.AreEqual (5, types.Count);
- }
-
- string GetName (IType t)
- {
- if (t.TypeParameters.Count == 0)
- return t.FullName;
- else
- return t.FullName + "`" + t.TypeParameters.Count;
- }
-
-/* [Test]
- public void GetObjectSubclasses ()
- {
- IType type = mainProject.GetType ("System.Object", true);
- Assert.IsNotNull (type);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetSubclasses (type, true))
- types.Add (t.FullName);
- }
-*/
-
- [Test]
- public void RewriteGenericType ()
- {
- // Check that the instantiated type cache is properly invalidated
- // when a generic type changes.
-
- List<IReturnType> args = new List<IReturnType> ();
- args.Add (new DomReturnType ("System.Int32"));
- IType type = mainProject.GetType ("CompletionDbTest.GenericRewrite", args);
- Assert.IsNotNull (type);
- Assert.IsTrue (type is InstantiatedType);
- Assert.IsTrue (type.FieldCount == 1);
-
- ReplaceFile ("GenericRewrite.cs", "Replacements/GenericRewrite.cs");
-
- type = mainProject.GetType ("CompletionDbTest.GenericRewrite", args);
- Assert.IsNotNull (type);
- Assert.IsTrue (type is InstantiatedType);
- Assert.IsTrue (type.FieldCount == 2);
- }
-
- [Test]
- public void GenericConstraintTest_Class ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.GenericConstraintTest1", 1, false);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.GenericConstraintTest1", type.FullName);
- Assert.AreEqual (1, type.TypeParameters.Count);
- Assert.AreEqual (1, type.FieldCount);
-
- List<IField> fs = new List<IField> (type.Fields);
- IReturnType rt = fs [0].ReturnType;
-
- IType fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("T", fieldType.Name);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest1.T"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (2, types.Count);
- }
-
- [Test]
- public void GenericConstraintTest_Struct ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.GenericConstraintTest2", 1, false);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.GenericConstraintTest2", type.FullName);
- Assert.AreEqual (1, type.TypeParameters.Count);
- Assert.AreEqual (1, type.FieldCount);
-
- List<IField> fs = new List<IField> (type.Fields);
- IReturnType rt = fs [0].ReturnType;
-
- IType fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("T", fieldType.Name);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest2.T"));
- Assert.IsTrue (types.Contains ("System.ValueType"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (3, types.Count);
- }
-
- [Test]
- public void GenericConstraintTest_New ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.GenericConstraintTest3", 1, false);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.GenericConstraintTest3", type.FullName);
- Assert.AreEqual (1, type.TypeParameters.Count);
- Assert.AreEqual (1, type.FieldCount);
-
- List<IField> fs = new List<IField> (type.Fields);
- IReturnType rt = fs [0].ReturnType;
-
- IType fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("T", fieldType.Name);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest3.T"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (2, types.Count);
- }
-
- [Test]
- public void GenericConstraintTest_WithBase ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.GenericConstraintTest4", 2, false);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.GenericConstraintTest4", type.FullName);
- Assert.AreEqual (2, type.TypeParameters.Count);
- Assert.AreEqual (2, type.FieldCount);
-
- // First field
-
- List<IField> fs = new List<IField> (type.Fields);
- IReturnType rt = fs [0].ReturnType;
-
- IType fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("T", fieldType.Name);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest4.T"));
- Assert.IsTrue (types.Contains ("Library1.CBin"));
- Assert.IsTrue (types.Contains ("Library2.CWidget"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (4, types.Count);
-
- // Second field
-
- rt = fs [1].ReturnType;
-
- fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("U", fieldType.Name);
-
- types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest4.U"));
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest4.T"));
- Assert.IsTrue (types.Contains ("Library1.CBin"));
- Assert.IsTrue (types.Contains ("Library2.CWidget"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (5, types.Count);
- }
-
- [Test]
- public void GenericConstraintTest_WithWrongBase ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.GenericConstraintTest5", 2, false);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.GenericConstraintTest5", type.FullName);
- Assert.AreEqual (2, type.TypeParameters.Count);
- Assert.AreEqual (2, type.FieldCount);
-
- // First field
-
- List<IField> fs = new List<IField> (type.Fields);
- IReturnType rt = fs [0].ReturnType;
-
- IType fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("T", fieldType.Name);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest5.T"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (2, types.Count);
-
- // Second field
-
- rt = fs [1].ReturnType;
-
- fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("U", fieldType.Name);
-
- types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest5.U"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (2, types.Count);
- }
-
- [Test]
- public void GenericConstraintTest_ClassAndInterface ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.GenericConstraintTest6", 1, false);
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.GenericConstraintTest6", type.FullName);
- Assert.AreEqual (1, type.TypeParameters.Count);
- Assert.AreEqual (1, type.FieldCount);
-
- List<IField> fs = new List<IField> (type.Fields);
- IReturnType rt = fs [0].ReturnType;
-
- IType fieldType = mainProject.GetType (rt);
- Assert.IsNotNull (fieldType);
- Assert.AreEqual ("T", fieldType.Name);
-
- List<string> types = new List<string> ();
- foreach (IType t in mainProject.GetInheritanceTree (fieldType))
- types.Add (t.FullName);
-
- Assert.IsTrue (types.Contains ("CompletionDbTest.GenericConstraintTest6.T"));
- Assert.IsTrue (types.Contains ("Library1.CBin"));
- Assert.IsTrue (types.Contains ("Library2.CWidget"));
- Assert.IsTrue (types.Contains ("System.ICloneable"));
- Assert.IsTrue (types.Contains ("System.Object"));
- Assert.AreEqual (5, types.Count);
- }
-
- [Test]
- public void PartialClass ()
- {
- IType type = mainProject.GetType ("CompletionDbTest.PartialTest");
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.PartialTest", type.FullName);
-
- List<string> members = new List<string> ();
- foreach (IMember mem in type.Members)
- members.Add (mem.Name);
-
- Assert.AreEqual (15, members.Count);
- Assert.IsTrue (members.Contains ("Field1"));
- Assert.IsTrue (members.Contains ("Property1"));
- Assert.IsTrue (members.Contains ("Event1"));
- Assert.IsTrue (members.Contains ("Method1"));
- Assert.IsTrue (members.Contains ("Inner1"));
- Assert.IsTrue (members.Contains ("Field2"));
- Assert.IsTrue (members.Contains ("Property2"));
- Assert.IsTrue (members.Contains ("Event2"));
- Assert.IsTrue (members.Contains ("Method2"));
- Assert.IsTrue (members.Contains ("Inner2"));
- Assert.IsTrue (members.Contains ("Field3"));
- Assert.IsTrue (members.Contains ("Property3"));
- Assert.IsTrue (members.Contains ("Event3"));
- Assert.IsTrue (members.Contains ("Method3"));
- Assert.IsTrue (members.Contains ("Inner3"));
-
- ReplaceFile ("PartialTest2.cs", "Replacements/PartialTest2.cs");
-
- type = mainProject.GetType ("CompletionDbTest.PartialTest");
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.PartialTest", type.FullName);
-
- members = new List<string> ();
- foreach (IMember mem in type.Members)
- members.Add (mem.Name);
-
- Assert.AreEqual (10, members.Count);
- Assert.IsTrue (members.Contains ("Field2"));
- Assert.IsTrue (members.Contains ("Property2"));
- Assert.IsTrue (members.Contains ("Event2"));
- Assert.IsTrue (members.Contains ("Method2"));
- Assert.IsTrue (members.Contains ("Inner2"));
- Assert.IsTrue (members.Contains ("Field3"));
- Assert.IsTrue (members.Contains ("Property3"));
- Assert.IsTrue (members.Contains ("Event3"));
- Assert.IsTrue (members.Contains ("Method3"));
- Assert.IsTrue (members.Contains ("Inner3"));
-
- ReplaceFile ("PartialTest2.cs", "Replacements/EmptyFile.cs");
-
- type = mainProject.GetType ("CompletionDbTest.PartialTest");
- Assert.IsNotNull (type);
- Assert.AreEqual ("CompletionDbTest.PartialTest", type.FullName);
-
- members = new List<string> ();
- foreach (IMember mem in type.Members)
- members.Add (mem.Name);
-
- Assert.AreEqual (5, members.Count);
- Assert.IsTrue (members.Contains ("Field3"));
- Assert.IsTrue (members.Contains ("Property3"));
- Assert.IsTrue (members.Contains ("Event3"));
- Assert.IsTrue (members.Contains ("Method3"));
- Assert.IsTrue (members.Contains ("Inner3"));
-
- ReplaceFile ("PartialTest1.cs", "Replacements/EmptyFile.cs");
-
- type = mainProject.GetType ("CompletionDbTest.PartialTest");
- Assert.IsNull (type);
- }
-
- [Test]
- public void NamespaceExistsTest ()
- {
- Assert.IsTrue (mainProject.NamespaceExists ("Level1"), "Level1 doesn't exist.");
- Assert.IsTrue (mainProject.NamespaceExists ("Level1.Level2"), "Level1.Level2 doesn't exist.");
- Assert.IsTrue (mainProject.NamespaceExists ("Level1.Level2.Level3"), "Level1.Level2.Level3 doesn't exist.");
- Assert.IsTrue (mainProject.NamespaceExists ("Level1.Level2.Level3.Level4"), "Level1.Level2.Level3.Level4 doesn't exist.");
- Assert.IsFalse (mainProject.NamespaceExists ("Level1.Level2.Level3.Level4.Level5"), "Level5 shouldn't exist.");
- Assert.IsFalse (mainProject.NamespaceExists ("Level1.Level3"), "level1.level3 shouldn't exist.");
- }
-
- [Test]
- public void ClassAttributeTest ()
- {
- // Simple get
- IType type = mainProject.GetType ("CompletionDbTest.AttributeTest");
- Assert.IsNotNull (type);
- Assert.AreEqual (1, type.Attributes.Count ());
- Assert.AreEqual ("Serializable", type.Attributes.First ().Name);
- }
-
- [Test]
- public void MemberAttributeTest ()
- {
- // Simple get
- IType type = mainProject.GetType ("CompletionDbTest.AttributeTest2");
- Assert.IsNotNull (type);
-
- var prop = type.Properties.First ();
- Assert.AreEqual (1, prop.Attributes.Count ());
- Assert.AreEqual ("Obsolete", prop.Attributes.First ().Name);
-
- var method = type.Methods.First ();
- Assert.AreEqual (1, method.Attributes.Count ());
- Assert.AreEqual ("Obsolete", method.Attributes.First ().Name);
- }
-
- [Test]
- public void CustomAttributeTest ()
- {
- // Simple get
- IType type = mainProject.GetType ("CompletionDbTest.AttributeTest3");
- Assert.IsNotNull (type);
- Assert.AreEqual (1, type.Attributes.Count ());
-
- var att = type.Attributes.First ();
- Assert.AreEqual ("Library1.TestAttribute", att.AttributeType.FullName);
- Assert.AreEqual (2, att.PositionalArguments.Count);
-
- var expr1 = att.PositionalArguments[0] as System.CodeDom.CodePrimitiveExpression;
- Assert.IsNotNull (expr1);
- Assert.AreEqual ("str1", expr1.Value);
-
- var expr2 = att.PositionalArguments[1] as System.CodeDom.CodePrimitiveExpression;
- Assert.IsNotNull (expr2);
- Assert.AreEqual (5, expr2.Value);
-
- Assert.AreEqual (1, att.NamedArguments.Count);
- Assert.IsTrue (att.NamedArguments.ContainsKey ("Blah"));
- var expr3 = att.NamedArguments["Blah"] as System.CodeDom.CodePrimitiveExpression;
- Assert.IsNotNull (expr3);
- Assert.AreEqual ("str2", expr3.Value);
- }
-
- }
-}
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/DomCompilationUnitTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/DomCompilationUnitTests.cs
deleted file mode 100644
index 68a7f30ff1..0000000000
--- a/main/tests/UnitTests/MonoDevelop.Projects/DomCompilationUnitTests.cs
+++ /dev/null
@@ -1,133 +0,0 @@
-// DomCompilationUnitTests.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using NUnit.Framework;
-using MonoDevelop.Projects.Dom;
-
-namespace UnitTests
-{
- [TestFixture()]
- public class DomCompilationUnitTests : UnitTests.TestBase
- {
- [Test()]
- public void TestGetNamespaceContentsCase1 ()
- {
- CompilationUnit unit = new CompilationUnit ("file.cs");
- unit.Add (new DomType ("ANamespace.AnotherNamespace.AClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.BClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.CClass"));
- unit.Add (new DomType ("ANamespace.AClass2"));
- unit.Add (new DomType ("ANamespace.BClass2"));
- unit.Add (new DomType ("CClass3"));
-
- List<IMember> member = new List<IMember> ();
- unit.GetNamespaceContents (member, "", true);
- Assert.AreEqual (2, member.Count);
- Namespace ns = member[0] as Namespace;
- Assert.IsNotNull (ns);
- Assert.AreEqual ("ANamespace", ns.Name);
-
- IType type = member[1] as IType;
- Assert.IsNotNull (type);
- Assert.AreEqual ("CClass3", type.FullName);
- }
-
- [Test()]
- public void TestGetNamespaceContentsCase2 ()
- {
- CompilationUnit unit = new CompilationUnit ("file.cs");
- unit.Add (new DomType ("ANamespace.AnotherNamespace.AClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.BClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.CClass"));
- unit.Add (new DomType ("ANamespace.AClass2"));
- unit.Add (new DomType ("ANamespace.BClass2"));
- unit.Add (new DomType ("CClass3"));
-
- List<IMember> member = new List<IMember> ();
- unit.GetNamespaceContents (member, "ANamespace", true);
-
- Assert.AreEqual (3, member.Count);
- Namespace ns = member[0] as Namespace;
- Assert.IsNotNull (ns);
- Assert.AreEqual ("AnotherNamespace", ns.Name);
-
- IType type = member[1] as IType;
- Assert.IsNotNull (type);
- Assert.AreEqual ("AClass2", type.Name);
-
- type = member[2] as IType;
- Assert.IsNotNull (type);
- Assert.AreEqual ("BClass2", type.Name);
- }
-
- [Test()]
- public void TestGetNamespaceContentsCase3 ()
- {
- CompilationUnit unit = new CompilationUnit ("file.cs");
- unit.Add (new DomType ("ANamespace.AnotherNamespace.AClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.BClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.CClass"));
- unit.Add (new DomType ("ANamespace.AClass2"));
- unit.Add (new DomType ("ANamespace.BClass2"));
- unit.Add (new DomType ("CClass3"));
-
- List<IMember> member = new List<IMember> ();
- unit.GetNamespaceContents (member, "ANamespace.AnotherNamespace", true);
- Assert.AreEqual (3, member.Count);
-
- IType type = member[0] as IType;
- Assert.IsNotNull (type);
- Assert.AreEqual ("AClass", type.Name);
-
- type = member[1] as IType;
- Assert.IsNotNull (type);
- Assert.AreEqual ("BClass", type.Name);
-
- type = member[2] as IType;
- Assert.IsNotNull (type);
- Assert.AreEqual ("CClass", type.Name);
- }
-
- [Test()]
- public void TestGetNamespaceContentsCase4 ()
- {
- CompilationUnit unit = new CompilationUnit ("file.cs");
- unit.Add (new DomType ("ANamespace.AnotherNamespace.AClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.BClass"));
- unit.Add (new DomType ("ANamespace.AnotherNamespace.CClass"));
- unit.Add (new DomType ("ANamespace.AClass2"));
- unit.Add (new DomType ("ANamespace.BClass2"));
- unit.Add (new DomType ("CClass3"));
-
- List<IMember> member = new List<IMember> ();
- unit.GetNamespaceContents (member, "ANamespace.NotExist", true);
- Assert.AreEqual (0, member.Count);
- }
- }
-}
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/DomPersistenceTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/DomPersistenceTests.cs
deleted file mode 100644
index 06238256eb..0000000000
--- a/main/tests/UnitTests/MonoDevelop.Projects/DomPersistenceTests.cs
+++ /dev/null
@@ -1,457 +0,0 @@
-//
-// DomPersistenceTests.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.CodeDom;
-using System.Collections.Generic;
-using System.IO;
-using NUnit.Framework;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Serialization;
-
-namespace MonoDevelop.Projects.DomTests
-{
- [TestFixture()]
- public class DomPersistenceTests : UnitTests.TestBase
- {
-
- [Test()]
- public void ReadWriteLocationTest ()
- {
- DomLocation input = new DomLocation (3, 9);
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, null, input);
- byte[] bytes = ms.ToArray ();
-
- DomLocation result = DomPersistence.ReadLocation (CreateReader (bytes), null);
- Assert.AreEqual (3, result.Line);
- Assert.AreEqual (9, result.Column);
- }
-
- [Test()]
- public void ReadWriteRegionTest ()
- {
- DomRegion input = new DomRegion (1, 2, 3, 4);
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomRegion result = DomPersistence.ReadRegion (CreateReader (bytes), DefaultNameDecoder);
- Assert.AreEqual (1, result.Start.Line);
- Assert.AreEqual (2, result.Start.Column);
- Assert.AreEqual (3, result.End.Line);
- Assert.AreEqual (4, result.End.Column);
- }
-
-
- [Test()]
- public void ReadWriteFieldTest ()
- {
- DomField input = new DomField ();
- input.Name = "TestField";
- input.Location = new DomLocation (5, 10);
- input.Documentation = "testDocumentation";
- input.Modifiers = Modifiers.Static;
- input.ReturnType = new DomReturnType ("System.String");
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomField result = DomPersistence.ReadField (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("TestField", result.Name);
- Assert.AreEqual ("testDocumentation", result.Documentation);
- Assert.AreEqual (new DomLocation (5, 10), result.Location);
- Assert.AreEqual (Modifiers.Static, result.Modifiers);
- Assert.AreEqual ("System.String", result.ReturnType.FullName);
- }
-
- [Test()]
- public void ReadWriteFieldTest2 ()
- {
- DomField input = new DomField ();
- input.Name = null;
- input.Location = DomLocation.Empty;
- input.Documentation = null;
- input.Modifiers = Modifiers.None;
- input.ReturnType = null;
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomField result = DomPersistence.ReadField (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual (null, result.Name);
- Assert.AreEqual (null, result.Documentation);
- Assert.AreEqual (DomLocation.Empty, result.Location);
- Assert.AreEqual (Modifiers.None, result.Modifiers);
- Assert.AreEqual (null, result.ReturnType);
- }
-
- [Test()]
- public void ReadWriteReturnTypeTest ()
- {
- DomReturnType input = new DomReturnType ();
- input.Name = "Test";
- input.Namespace = "Namespace";
- input.ArrayDimensions = 5;
- input.IsByRef = true;
- input.IsNullable = true;
- input.PointerNestingLevel = 666;
- input.AddTypeParameter (new DomReturnType ("System.String"));
- input.AddTypeParameter (new DomReturnType ("System.Int32"));
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- IReturnType result = DomPersistence.ReadReturnType (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("Test", result.Name);
- Assert.AreEqual ("Namespace", result.Namespace);
- Assert.AreEqual ("Namespace.Test", result.FullName);
- Assert.AreEqual (5, result.ArrayDimensions);
- Assert.AreEqual (true, result.IsByRef);
- Assert.AreEqual (true, result.IsNullable);
- Assert.AreEqual ("System.String", result.GenericArguments[0].FullName);
- Assert.AreEqual ("System.Int32", result.GenericArguments[1].FullName);
- }
-
- [Test()]
- public void ReadWriteMethodTest ()
- {
- DomMethod input = new DomMethod ();
- input.Name = "Test";
- input.MethodModifier = MethodModifier.IsConstructor;
- input.Add (new DomParameter (input, "par1", DomReturnType.Void));
- input.AddTypeParameter (new TypeParameter ("T"));
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomMethod result = DomPersistence.ReadMethod (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("Test", result.Name);
- Assert.AreEqual (true, result.IsConstructor);
- Assert.AreEqual ("par1", result.Parameters [0].Name);
- Assert.AreEqual ("Void", result.Parameters [0].ReturnType.Name);
- Assert.AreEqual (1, result.TypeParameters.Count);
- Assert.AreEqual ("T", result.TypeParameters [0].Name);
- }
-
- [Test()]
- public void ReadWriteDelegateTest ()
- {
- DomType input = DomType.CreateDelegate (null, "TestDelegate", new DomLocation (10, 10), DomReturnType.Void, new List<IParameter> ());
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomType result = DomPersistence.ReadType (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("TestDelegate", result.Name);
- Assert.AreEqual (ClassType.Delegate, result.ClassType);
- }
-
- [Test()]
- public void ReadWritePropertyTest ()
- {
- DomProperty input = new DomProperty ();
- input.Name = "Test";
- input.PropertyModifier = PropertyModifier.IsIndexer | PropertyModifier.HasGet | PropertyModifier.HasSet;
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomProperty result = DomPersistence.ReadProperty (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("Test", result.Name);
- Assert.AreEqual (true, result.IsIndexer);
- Assert.AreEqual (true, result.HasGet);
- Assert.AreEqual (true, result.HasSet);
- }
-
- [Test()]
- public void ReadWriteEventTest ()
- {
- DomEvent input = new DomEvent ();
- input.Name = "Test";
- input.AddMethod = new DomMethod ("AddMethod", Modifiers.New, MethodModifier.None, DomLocation.Empty, DomRegion.Empty);
- input.RemoveMethod = new DomMethod ("RemoveMethod", Modifiers.New, MethodModifier.None, DomLocation.Empty, DomRegion.Empty);
- input.RaiseMethod = new DomMethod ("RaiseMethod", Modifiers.New, MethodModifier.None, DomLocation.Empty, DomRegion.Empty);
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomEvent result = DomPersistence.ReadEvent (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("Test", result.Name);
- Assert.AreEqual ("AddMethod", result.AddMethod.Name);
- Assert.AreEqual ("RemoveMethod", result.RemoveMethod.Name);
- Assert.AreEqual ("RaiseMethod", result.RaiseMethod.Name);
- }
-
- [Test()]
- public void ReadWriteTypeTest ()
- {
- DomType input = new DomType ();
- input.Name = "Test";
- input.ClassType = ClassType.Struct;
- input.BaseType = new DomReturnType ("BaseClass");
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomType result = DomPersistence.ReadType (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("Test", result.Name);
- Assert.AreEqual (ClassType.Struct, result.ClassType);
- Assert.AreEqual ("BaseClass", result.BaseType.Name);
- }
-
- [Test()]
- public void ReadWriteTypeTestComplex ()
- {
- DomType input = new DomType ();
-
- input.Name = "Test";
- input.ClassType = ClassType.Struct;
- input.BaseType = new DomReturnType ("BaseClass");
- input.AddInterfaceImplementation (new DomReturnType ("Interface1"));
- input.AddInterfaceImplementation (new DomReturnType ("Interface2"));
-
- input.Add (new DomMethod ("TestMethod", Modifiers.None, MethodModifier.None, DomLocation.Empty, DomRegion.Empty));
- input.Add (new DomMethod (".ctor", Modifiers.None, MethodModifier.IsConstructor, DomLocation.Empty, DomRegion.Empty));
-
- input.Add (new DomField ("TestField", Modifiers.None, DomLocation.Empty, DomReturnType.Void));
- input.Add (new DomProperty ("TestProperty", Modifiers.None, DomLocation.Empty, DomRegion.Empty, DomReturnType.Void));
- input.Add (new DomEvent ("TestEvent", Modifiers.None, DomLocation.Empty, DomReturnType.Void));
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, input);
- byte[] bytes = ms.ToArray ();
-
- DomType result = DomPersistence.ReadType (CreateReader (bytes), DefaultNameDecoder, null);
- Assert.AreEqual ("Test", result.Name);
- Assert.AreEqual (ClassType.Struct, result.ClassType);
- Assert.AreEqual ("BaseClass", result.BaseType.Name);
- Assert.AreEqual (1, result.MethodCount);
- Assert.AreEqual (1, result.ConstructorCount);
- Assert.AreEqual (1, result.FieldCount);
- Assert.AreEqual (1, result.PropertyCount);
- Assert.AreEqual (1, result.EventCount);
-
- }
-
- [Test()]
- public void ReadWriteAttributeTest ()
- {
- DomAttribute attr = new DomAttribute ();
-
- CodePropertyReferenceExpression exp1 = new CodePropertyReferenceExpression ();
- exp1.TargetObject = new CodeTypeReferenceExpression ("SomeType");
- exp1.PropertyName = "SomeProperty";
-
- CodeTypeOfExpression exp2 = new CodeTypeOfExpression ("SomeTypeOf");
-
- CodeBinaryOperatorExpression exp3 = new CodeBinaryOperatorExpression ();
- exp3.Left = new CodePrimitiveExpression ("one");
- exp3.Right = new CodePrimitiveExpression ("two");
- exp3.Operator = CodeBinaryOperatorType.Add;
-
- CodePrimitiveExpression exp4 = new CodePrimitiveExpression (37);
-
- attr.AddPositionalArgument (exp1);
- attr.AddPositionalArgument (exp2);
- attr.AddPositionalArgument (exp3);
- attr.AddPositionalArgument (exp4);
-
- MemoryStream ms = new MemoryStream ();
- BinaryWriter writer = new BinaryWriter (ms);
- DomPersistence.Write (writer, DefaultNameEncoder, attr);
- byte[] bytes = ms.ToArray ();
- DomAttribute result = DomPersistence.ReadAttribute (CreateReader (bytes), DefaultNameDecoder, null);
-
- Assert.AreEqual (4, result.PositionalArguments.Count);
-
- Assert.AreEqual (typeof(CodePropertyReferenceExpression), result.PositionalArguments [0].GetType ());
- CodePropertyReferenceExpression rexp1 = (CodePropertyReferenceExpression) result.PositionalArguments [0];
- Assert.AreEqual (typeof(CodeTypeReferenceExpression), rexp1.TargetObject.GetType ());
- Assert.AreEqual ("SomeType", ((CodeTypeReferenceExpression)rexp1.TargetObject).Type.BaseType);
- Assert.AreEqual ("SomeProperty", rexp1.PropertyName);
-
- Assert.AreEqual (typeof(CodeTypeOfExpression), result.PositionalArguments [1].GetType ());
- Assert.AreEqual ("SomeTypeOf", ((CodeTypeOfExpression)result.PositionalArguments [1]).Type.BaseType);
-
- Assert.AreEqual (typeof(CodeBinaryOperatorExpression), result.PositionalArguments [2].GetType ());
- CodeBinaryOperatorExpression rexp3 = (CodeBinaryOperatorExpression) result.PositionalArguments [2];
- Assert.AreEqual (typeof(CodePrimitiveExpression), rexp3.Left.GetType ());
- Assert.AreEqual ("one", ((CodePrimitiveExpression)rexp3.Left).Value);
- Assert.AreEqual (typeof(CodePrimitiveExpression), rexp3.Right.GetType ());
- Assert.AreEqual ("two", ((CodePrimitiveExpression)rexp3.Right).Value);
-
- Assert.AreEqual (typeof(CodePrimitiveExpression), result.PositionalArguments [3].GetType ());
- Assert.AreEqual (37, ((CodePrimitiveExpression)result.PositionalArguments [3]).Value);
- }
-
- static BinaryReader CreateReader (byte[] bytes)
- {
- return new BinaryReader (new MemoryStream (bytes));
- }
-
-// Doesn't work: ?
-// byte[] Write<T> (T input)
-// {
-// MemoryStream ms = new MemoryStream ();
-// BinaryWriter writer = new BinaryWriter (ms);
-// DomPersistence.Write (writer, null, input);
-// return ms.ToArray ();
-// }
-
-
- static StringNameTable DefaultNameEncoder;
- static StringNameTable DefaultNameDecoder;
-
- static DomPersistenceTests ()
- {
- DefaultNameEncoder = new StringNameTable (sharedNameTable);
- DefaultNameDecoder = new StringNameTable (sharedNameTable);
- }
-
- static readonly string[] sharedNameTable = new string[] {
- "", // 505195
- "System.Void", // 116020
- "To be added", // 78598
- "System.Int32", // 72669
- "System.String", // 72097
- "System.Object", // 48530
- "System.Boolean", // 46200
- ".ctor", // 39938
- "System.IntPtr", // 35184
- "To be added.", // 19082
- "value", // 11906
- "System.Byte", // 8524
- "To be added: an object of type 'string'", // 7928
- "e", // 7858
- "raw", // 7830
- "System.IAsyncResult", // 7760
- "System.Type", // 7518
- "name", // 7188
- "object", // 6982
- "System.UInt32", // 6966
- "index", // 6038
- "To be added: an object of type 'int'", // 5196
- "System.Int64", // 4166
- "callback", // 4158
- "System.EventArgs", // 4140
- "method", // 4030
- "System.Enum", // 3980
- "value__", // 3954
- "Invoke", // 3906
- "result", // 3856
- "System.AsyncCallback", // 3850
- "System.MulticastDelegate", // 3698
- "BeginInvoke", // 3650
- "EndInvoke", // 3562
- "node", // 3416
- "sender", // 3398
- "context", // 3310
- "System.EventHandler", // 3218
- "System.Double", // 3206
- "type", // 3094
- "x", // 3056
- "System.Single", // 2940
- "data", // 2930
- "args", // 2926
- "System.Char", // 2813
- "Gdk.Key", // 2684
- "ToString", // 2634
- "'a", // 2594
- "System.Drawing.Color", // 2550
- "y", // 2458
- "To be added: an object of type 'object'", // 2430
- "System.DateTime", // 2420
- "message", // 2352
- "GLib.GType", // 2292
- "o", // 2280
- "a <see cref=\"T:System.Int32\" />", // 2176
- "path", // 2062
- "obj", // 2018
- "Nemerle.Core.list`1", // 1950
- "System.Windows.Forms", // 1942
- "System.Collections.ArrayList", // 1918
- "a <see cref=\"T:System.String\" />", // 1894
- "key", // 1868
- "Add", // 1864
- "arg0", // 1796
- "System.IO.Stream", // 1794
- "s", // 1784
- "arg1", // 1742
- "provider", // 1704
- "System.UInt64", // 1700
- "System.Drawing.Rectangle", // 1684
- "System.IFormatProvider", // 1684
- "gch", // 1680
- "System.Exception", // 1652
- "Equals", // 1590
- "System.Drawing.Pen", // 1584
- "count", // 1548
- "System.Collections.IEnumerator", // 1546
- "info", // 1526
- "Name", // 1512
- "System.Attribute", // 1494
- "gtype", // 1470
- "To be added: an object of type 'Type'", // 1444
- "System.Collections.Hashtable", // 1416
- "array", // 1380
- "System.Int16", // 1374
- "Gtk", // 1350
- "System.ComponentModel.ITypeDescriptorContext", // 1344
- "System.Collections.ICollection", // 1330
- "Dispose", // 1330
- "Gtk.Widget", // 1326
- "System.Runtime.Serialization.StreamingContext", // 1318
- "Nemerle.Compiler.Parsetree.PExpr", // 1312
- "System.Guid", // 1310
- "i", // 1302
- "Gtk.TreeIter", // 1300
- "text", // 1290
- "System.Runtime.Serialization.SerializationInfo", // 1272
- "state", // 1264
- "Remove" // 1256
- };
- }
-}
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/DomTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/DomTests.cs
deleted file mode 100644
index 29760a7a29..0000000000
--- a/main/tests/UnitTests/MonoDevelop.Projects/DomTests.cs
+++ /dev/null
@@ -1,228 +0,0 @@
-//
-// DomTests.cs
-//
-// Author:
-// Mike Krüger <mkrueger@novell.com>
-//
-// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using NUnit.Framework;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Serialization;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Core.Assemblies;
-
-namespace MonoDevelop.Projects.DomTests
-{
- [TestFixture()]
- public class DomTests : UnitTests.TestBase
- {
- [Test()]
- public void InstantiatedMethodByArgumentTest ()
- {
- // build "T MyMethod<T> (T a)"
- DomMethod method = new DomMethod ();
- method.Name = "MyMethod";
- method.ReturnType = new DomReturnType ("T");
- method.AddTypeParameter (new TypeParameter ("T"));
- method.Add (new DomParameter (method, "a", new DomReturnType ("T")));
-
- // give int as param type
- List<IReturnType> genArgs = new List<IReturnType> ();
- List<IReturnType> args = new List<IReturnType> ();
- args.Add (DomReturnType.Int32);
- IMethod instMethod = DomMethod.CreateInstantiatedGenericMethod (method, genArgs, args);
-
- // check
- Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.ReturnType.FullName);
- Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.Parameters[0].ReturnType.FullName);
- }
-
- [Test()]
- public void InstantiatedMethodByParameterTest ()
- {
- // build "T MyMethod<T> (T[] a)"
- DomMethod method = new DomMethod ();
- method.Name = "MyMethod";
- method.ReturnType = new DomReturnType ("T");
- method.AddTypeParameter (new TypeParameter ("T"));
- DomReturnType returnType = new DomReturnType ("T");
- returnType.ArrayDimensions = 1;
- method.Add (new DomParameter (method, "a", returnType));
-
- // give int[] as param type.
- List<IReturnType> genArgs = new List<IReturnType> ();
- List<IReturnType> args = new List<IReturnType> ();
- returnType = new DomReturnType (DomReturnType.Int32.FullName);
- returnType.ArrayDimensions = 1;
- args.Add (returnType);
-
- IMethod instMethod = DomMethod.CreateInstantiatedGenericMethod (method, genArgs, args);
-
- // check (note that return type should be int and not int[])
- Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.ReturnType.FullName);
- Assert.AreEqual (0, instMethod.ReturnType.ArrayDimensions);
- Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.Parameters[0].ReturnType.FullName);
- }
-
- [Test()]
- public void InstantiatedMethodByArgumentTest_Complex ()
- {
- // build "T MyMethod<T,S> (S b, KeyValuePair<S, T> a)"
- DomMethod method = new DomMethod ();
- method.Name = "MyMethod";
- method.ReturnType = new DomReturnType ("T");
- method.AddTypeParameter (new TypeParameter ("T"));
- method.AddTypeParameter (new TypeParameter ("S"));
- method.Add (new DomParameter (method, "b", new DomReturnType ("S")));
-
- DomReturnType returnType = new DomReturnType ("KeyValuePair");
- returnType.AddTypeParameter (new DomReturnType ("T"));
- returnType.AddTypeParameter (new DomReturnType ("S"));
- method.Add (new DomParameter (method, "a", returnType));
-
- // give int, object as param type
- List<IReturnType> genArgs = new List<IReturnType> ();
- List<IReturnType> args = new List<IReturnType> ();
- genArgs.Add (DomReturnType.Int32);
- genArgs.Add (DomReturnType.Object);
-
- IMethod instMethod = DomMethod.CreateInstantiatedGenericMethod (method, genArgs, args);
-
- // check
- Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.ReturnType.FullName);
- Assert.AreEqual (DomReturnType.Object.FullName, instMethod.Parameters[0].ReturnType.FullName);
-
- Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.Parameters[1].ReturnType.GenericArguments[0].FullName);
- Assert.AreEqual (DomReturnType.Object.FullName, instMethod.Parameters[1].ReturnType.GenericArguments[1].FullName);
- }
-
- [Test()]
- public void ExtensionMethodTest ()
- {
- // build "T MyMethod<T, S> (this KeyValuePair<T, S> a, S b)"
- DomMethod method = new DomMethod ();
- method.Name = "MyMethod";
- method.ReturnType = new DomReturnType ("T");
- method.AddTypeParameter (new TypeParameter ("T"));
- method.AddTypeParameter (new TypeParameter ("S"));
-
- DomReturnType returnType = new DomReturnType ("KeyValuePair");
- returnType.AddTypeParameter (new DomReturnType ("T"));
- returnType.AddTypeParameter (new DomReturnType ("S"));
- method.Add (new DomParameter (method, "a", returnType));
- method.Add (new DomParameter (method, "b", new DomReturnType ("S")));
-
- // Build extendet type KeyValuePair<int, object>
- DomType type = new DomType ("KeyValuePair");
- type.AddTypeParameter (new TypeParameter ("T"));
- type.AddTypeParameter (new TypeParameter ("S"));
- IType extType = DomType.CreateInstantiatedGenericTypeInternal (type, new IReturnType[] { DomReturnType.Int32, DomReturnType.Object });
- Console.WriteLine (extType);
-
- // extend method
- List<IReturnType> genArgs = new List<IReturnType> ();
- List<IReturnType> args = new List<IReturnType> ();
-
- ExtensionMethod extMethod = new ExtensionMethod (extType, method, genArgs, args);
-
- Console.WriteLine (extMethod);
- // check
- Assert.AreEqual (DomReturnType.Int32.FullName, extMethod.ReturnType.FullName);
- Assert.AreEqual (DomReturnType.Object.FullName, extMethod.Parameters[0].ReturnType.FullName);
- }
-
-
- [Test()]
- public void ExtensionMethodPreserveParameterTest ()
- {
- // build "T MyMethod<T, S> (T a, S b)"
- DomMethod method = new DomMethod ();
- method.Name = "MyMethod";
- method.ReturnType = new DomReturnType ("T");
- method.AddTypeParameter (new TypeParameter ("T"));
- method.AddTypeParameter (new TypeParameter ("S"));
-
- method.Add (new DomParameter (method, "a", new DomReturnType ("T")));
- method.Add (new DomParameter (method, "b", new DomReturnType ("S")));
-
- // extend method
- List<IReturnType> genArgs = new List<IReturnType> ();
- List<IReturnType> args = new List<IReturnType> ();
- DomType extType = new DomType ("MyType");
-
- ExtensionMethod extMethod = new ExtensionMethod (extType, method, genArgs, args);
-
- // check for MyType MyMethod<S> (S b)
- Assert.AreEqual ("MyType", extMethod.ReturnType.FullName);
- Assert.AreEqual ("S", extMethod.Parameters[0].ReturnType.FullName);
- Assert.AreEqual (1, extMethod.TypeParameters.Count);
- Assert.AreEqual ("S", extMethod.TypeParameters[0].Name);
- }
-
- [Test()]
- public void InstantiatedMethodByArgumentTestComplex2 ()
- {
- // build "T MyMethod<T> (MyType<T> a)"
- DomMethod method = new DomMethod ();
- method.Name = "MyMethod";
- method.ReturnType = new DomReturnType ("T");
- method.AddTypeParameter (new TypeParameter ("T"));
-
- DomReturnType returnType = new DomReturnType ("MyType");
- returnType.AddTypeParameter (new DomReturnType ("T"));
- method.Add (new DomParameter (method, "a", returnType));
-
- // give int as param type
- List<IReturnType> genArgs = new List<IReturnType> ();
- List<IReturnType> args = new List<IReturnType> ();
- returnType = new DomReturnType ("MyType");
- returnType.AddTypeParameter (DomReturnType.Int32);
- args.Add (returnType);
- IMethod instMethod = DomMethod.CreateInstantiatedGenericMethod (method, genArgs, args);
-
- // check
- Assert.AreEqual (DomReturnType.Int32.FullName, instMethod.ReturnType.FullName);
- }
-
- [Test()]
- public void ParseAssemblyUriTests ()
- {
- TargetRuntime runtime;
- TargetFramework fx;
- string file;
- ProjectDomService.ParseAssemblyUri ("Assembly:Mono 2.4.2.3:/usr/lib/mono/2.0/mscorlib.dll", out runtime, out fx, out file);
- Assert.AreEqual ("/usr/lib/mono/2.0/mscorlib.dll", file);
-
- ProjectDomService.ParseAssemblyUri ("Assembly:MS.NET:C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\mscorlib.dll", out runtime, out fx, out file);
- Assert.AreEqual ("C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\mscorlib.dll", file);
-
- ProjectDomService.ParseAssemblyUri ("Assembly:Mono r142024 Wed Sep 16 11:39:25 BST 2009:/usr/local/lib/mono/2.0/mscorlib.dll", out runtime, out fx, out file);
- Assert.AreEqual ("/usr/local/lib/mono/2.0/mscorlib.dll", file);
-
-
- }
-
- }
-}
diff --git a/main/tests/UnitTests/MonoDevelop.Projects/SolutionTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/SolutionTests.cs
index 4b288fe6f4..512f93ebb9 100644
--- a/main/tests/UnitTests/MonoDevelop.Projects/SolutionTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Projects/SolutionTests.cs
@@ -391,7 +391,7 @@ namespace MonoDevelop.Projects
SolutionConfigurationSelector config = (SolutionConfigurationSelector) "Debug";
- Assert.IsTrue (p.NeedsBuilding (config));
+ Assert.IsTrue (p. NeedsBuilding (config));
Assert.IsTrue (lib1.NeedsBuilding (config));
Assert.IsTrue (lib2.NeedsBuilding (config));