From dea25f9bbf22567810d7ebf4023d7cd1c8a9e5fa Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 1 Jan 2014 14:33:59 +0000 Subject: [PATCH] Update EnvDTE.CodeFunction tests. --- .../Project/Src/EnvDTE/CodeFunction.cs | 6 +- .../Test/PackageManagement.Tests.csproj | 8 - .../Test/Src/EnvDTE/CodeFunction2Tests.cs | 266 +++--- .../Test/Src/EnvDTE/CodeFunctionTests.cs | 756 +++++++++--------- .../Test/Src/Helpers/CompilationUnitHelper.cs | 50 -- .../Test/Src/Helpers/MethodHelper.cs | 182 ----- .../Src/Helpers/MethodOrPropertyHelper.cs | 33 - .../Test/Src/Helpers/ProjectContentHelper.cs | 239 ------ .../Test/Src/Helpers/ReturnTypeHelper.cs | 41 - .../Test/Src/Helpers/TypeParameterHelper.cs | 32 - .../Test/Src/Helpers/UsingHelper.cs | 44 - .../Test/Src/Helpers/UsingScopeHelper.cs | 46 -- 12 files changed, 519 insertions(+), 1184 deletions(-) delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/CompilationUnitHelper.cs delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodHelper.cs delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodOrPropertyHelper.cs delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectContentHelper.cs delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ReturnTypeHelper.cs delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TypeParameterHelper.cs delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingHelper.cs delete mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingScopeHelper.cs diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeFunction.cs b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeFunction.cs index dbb10db097..33b952cae5 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeFunction.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeFunction.cs @@ -57,9 +57,9 @@ namespace ICSharpCode.PackageManagement.EnvDTE public virtual bool CanOverride { get { return method.IsOverridable; } set { - if (value && !method.IsOverridable) { - context.CodeGenerator.MakeVirtual(method); - } +// if (value && !method.IsOverridable) { +// context.CodeGenerator.MakeVirtual(method); +// } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj index 33ed212174..4b20cb2128 100644 --- a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj +++ b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj @@ -114,7 +114,6 @@ - @@ -123,12 +122,8 @@ - - - - @@ -139,9 +134,6 @@ - - - diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunction2Tests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunction2Tests.cs index d8a6d5383f..a59b643e4b 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunction2Tests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunction2Tests.cs @@ -1,131 +1,135 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using ICSharpCode.PackageManagement.EnvDTE; -//using NUnit.Framework; -//using PackageManagement.Tests.Helpers; -// -//namespace PackageManagement.Tests.EnvDTE -//{ -// [TestFixture] -// public class CodeFunction2Tests -// { -// CodeFunction2 codeFunction; -// MethodHelper helper; -// -// [SetUp] -// public void Init() -// { -// helper = new MethodHelper(); -// } -// -// void CreatePublicFunction(string name) -// { -// helper.CreatePublicMethod(name); -// CreateFunction(); -// } -// -// void CreateFunction() -// { -// codeFunction = new CodeFunction2(helper.Method); -// } -// -// [Test] -// public void OverrideKind_OrdinaryMethod_ReturnsNone() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// -// global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindNone, kind); -// } -// -// [Test] -// public void OverrideKind_AbstractMethod_ReturnsAbstract() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// helper.MakeMethodAbstract(); -// -// global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindAbstract, kind); -// } -// -// [Test] -// public void OverrideKind_VirtualMethod_ReturnsVirtual() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// helper.MakeMethodVirtual(); -// -// global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindVirtual, kind); -// } -// -// [Test] -// public void OverrideKind_MethodOverride_ReturnsOverride() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// helper.MakeMethodOverride(); -// -// global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindOverride, kind); -// } -// -// [Test] -// public void OverrideKind_SealedMethod_ReturnsSealed() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// helper.MakeMethodSealed(); -// -// global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindSealed, kind); -// } -// -// [Test] -// public void OverrideKind_MethodHiddenByNewKeyword_ReturnsNew() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// helper.MakeMethodNewOverride(); -// -// global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindNew, kind); -// } -// -// [Test] -// public void IsGeneric_MethodHasTypeParameter_ReturnsTrue() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// helper.AddTypeParameter("TResult"); -// -// bool generic = codeFunction.IsGeneric; -// -// Assert.IsTrue(generic); -// } -// -// [Test] -// public void IsGeneric_MethodHasTypeParameters_ReturnsFalse() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// helper.NoTypeParameters(); -// -// bool generic = codeFunction.IsGeneric; -// -// Assert.IsFalse(generic); -// } -// -// [Test] -// public void IsGeneric_MethodTypeParametersIsNull_ReturnsFalse() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// -// bool generic = codeFunction.IsGeneric; -// -// Assert.IsFalse(generic); -// } -// } -//} +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.PackageManagement.EnvDTE; +using NUnit.Framework; + +namespace PackageManagement.Tests.EnvDTE +{ + [TestFixture] + public class CodeFunction2Tests : CodeModelTestBase + { + CodeFunction2 codeFunction; + + void CreateFunction(string code) + { + AddCodeFile("class.cs", code); + + IMethod method = assemblyModel + .TopLevelTypeDefinitions + .First() + .Members + .First() + .Resolve() as IMethod; + + codeFunction = new CodeFunction2(codeModelContext, method); + } + + [Test] + public void OverrideKind_OrdinaryMethod_ReturnsNone() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; + + Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindNone, kind); + } + + [Test] + public void OverrideKind_AbstractMethod_ReturnsAbstract() + { + CreateFunction( + "public class MyClass {\r\n" + + " public abstract void MyFunction();\r\n" + + "}"); + + global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; + + Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindAbstract, kind); + } + + [Test] + public void OverrideKind_VirtualMethod_ReturnsVirtual() + { + CreateFunction( + "public class MyClass {\r\n" + + " public virtual void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; + + Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindVirtual, kind); + } + + [Test] + public void OverrideKind_MethodOverride_ReturnsOverride() + { + CreateFunction( + "public class MyClass {\r\n" + + " public override string ToString() { return \"MyClass\"; }\r\n" + + "}"); + + global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; + + Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindOverride, kind); + } + + [Test] + public void OverrideKind_SealedMethod_ReturnsSealed() + { + CreateFunction( + "public class MyClass {\r\n" + + " public sealed void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; + + Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindSealed, kind); + } + + [Test] + public void OverrideKind_MethodHiddenByNewKeyword_ReturnsNew() + { + CreateFunction( + "public class MyClass {\r\n" + + " public new string ToString() { return \"MyClass\"; }\r\n" + + "}"); + + global::EnvDTE.vsCMOverrideKind kind = codeFunction.OverrideKind; + + Assert.AreEqual(global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindNew, kind); + } + + [Test] + public void IsGeneric_MethodHasTypeParameter_ReturnsTrue() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + bool generic = codeFunction.IsGeneric; + + Assert.IsTrue(generic); + } + + [Test] + public void IsGeneric_MethodHasNoTypeParameters_ReturnsFalse() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + bool generic = codeFunction.IsGeneric; + + Assert.IsFalse(generic); + } + } +} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunctionTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunctionTests.cs index 7fae268b8d..49b247d9cf 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunctionTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunctionTests.cs @@ -1,381 +1,387 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using ICSharpCode.PackageManagement; -//using ICSharpCode.PackageManagement.EnvDTE; -//using ICSharpCode.SharpDevelop.Dom; -//using NUnit.Framework; -//using PackageManagement.Tests.Helpers; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.EnvDTE -//{ -// [TestFixture] -// public class CodeFunctionTests -// { -// CodeFunction codeFunction; -// MethodHelper helper; -// IVirtualMethodUpdater methodUpdater; -// -// [SetUp] -// public void Init() -// { -// helper = new MethodHelper(); -// } -// -// void CreatePublicFunction(string name) -// { -// helper.CreatePublicMethod(name); -// CreateFunction(); -// } -// -// void CreatePrivateFunction(string name) -// { -// helper.CreatePrivateMethod(name); -// CreateFunction(); -// } -// +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.PackageManagement; +using ICSharpCode.PackageManagement.EnvDTE; +using NUnit.Framework; +using PackageManagement.Tests.Helpers; + +namespace PackageManagement.Tests.EnvDTE +{ + [TestFixture] + public class CodeFunctionTests : CodeModelTestBase + { + CodeFunction codeFunction; + IVirtualMethodUpdater methodUpdater; + // void CreateFunction() // { // methodUpdater = MockRepository.GenerateStub(); // codeFunction = new CodeFunction(helper.Method, null, methodUpdater); // } -// -// void CreatePublicConstructor(string name) -// { -// helper.CreatePublicConstructor(name); -// CreateFunction(); -// } -// -// void SetDeclaringTypeAsInterface(string name) -// { -// helper.AddDeclaringTypeAsInterface(name); -// } -// -// void SetDeclaringType(string name) -// { -// helper.AddDeclaringType(name); -// } -// -// void AddParameterToMethod(string name) -// { -// helper.AddParameter(name); -// } -// -// void AddParameterToMethod(string type, string name) -// { -// helper.AddParameter(type, name); -// } -// -// void AddReturnTypeToMethod(string type) -// { -// helper.AddReturnTypeToMethod(type); -// } -// -// void MakeMethodStatic() -// { -// helper.MakeMethodStatic(); -// } -// -// void MakeMethodAbstract() -// { -// helper.MakeMethodAbstract(); -// } -// -// void MakeMethodVirtual() -// { -// helper.MakeMethodVirtual(); -// } -// -// void AddMethodAttribute(string attributeTypeName) -// { -// helper.AddAttributeToMethod(attributeTypeName); -// } -// -// void MakeMethodOverridable() -// { -// helper.MakeMethodOverridable(); -// } -// -// [Test] -// public void Access_PublicFunction_ReturnsPublic() -// { -// CreatePublicFunction("Class1.MyFunction"); -// -// global::EnvDTE.vsCMAccess access = codeFunction.Access; -// -// Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPublic, access); -// } -// -// [Test] -// public void Access_PrivateFunction_ReturnsPrivate() -// { -// CreatePrivateFunction("Class1.MyFunction"); -// -// global::EnvDTE.vsCMAccess access = codeFunction.Access; -// -// Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPrivate, access); -// } -// -// [Test] -// public void GetStartPoint_FunctionStartsAtColumn3_ReturnsPointWithOffset3() -// { -// CreatePublicFunction("Class1.MyFunction"); -// SetDeclaringType("Class1"); -// helper.FunctionStartsAtColumn(3); -// -// global::EnvDTE.TextPoint point = codeFunction.GetStartPoint(); -// int offset = point.LineCharOffset; -// -// Assert.AreEqual(3, offset); -// } -// -// [Test] -// public void GetStartPoint_FunctionStartsAtLine2_ReturnsPointWithLine2() -// { -// CreatePublicFunction("Class1.MyFunction"); -// SetDeclaringType("Class1"); -// helper.FunctionStartsAtLine(2); -// -// global::EnvDTE.TextPoint point = codeFunction.GetStartPoint(); -// int line = point.Line; -// -// Assert.AreEqual(2, line); -// } -// -// [Test] -// public void GetEndPoint_FunctionBodyEndsAtColumn4_ReturnsPointWithOffset4() -// { -// CreatePublicFunction("Class1.MyFunction"); -// SetDeclaringType("Class1"); -// helper.FunctionBodyEndsAtColumn(4); -// -// global::EnvDTE.TextPoint point = codeFunction.GetEndPoint(); -// int offset = point.LineCharOffset; -// -// Assert.AreEqual(4, offset); -// } -// -// [Test] -// public void GetEndPoint_FunctionBodyEndsAtLine4_ReturnsPointWithLine4() -// { -// CreatePublicFunction("Class1.MyFunction"); -// SetDeclaringType("Class1"); -// helper.FunctionBodyEndsAtLine(4); -// -// global::EnvDTE.TextPoint point = codeFunction.GetEndPoint(); -// int line = point.Line; -// -// Assert.AreEqual(4, line); -// } -// -// [Test] -// public void Kind_PublicFunction_ReturnsFunction() -// { -// CreatePublicFunction("MyFunction"); -// -// global::EnvDTE.vsCMElement kind = codeFunction.Kind; -// -// Assert.AreEqual(global::EnvDTE.vsCMElement.vsCMElementFunction, kind); -// } -// -// [Test] -// public void GetEndPoint_InterfaceMethod_ReturnsMethodsDeclarationRegionEndNotBodyRegionEnd() -// { -// CreatePublicFunction("MyInterface.MyMethod"); -// SetDeclaringTypeAsInterface("MyInterface"); -// helper.SetRegion(new DomRegion(1, 1, 1, 10)); -// helper.SetBodyRegion(new DomRegion(1, 10, 0, 0)); -// -// global::EnvDTE.TextPoint point = codeFunction.GetEndPoint(); -// -// Assert.AreEqual(1, point.Line); -// Assert.AreEqual(10, point.LineCharOffset); -// } -// -// [Test] -// public void Parameters_MethodHasNoParameters_ReturnsEmptyListOfItems() -// { -// CreatePublicFunction("MyClass.MyMethod"); -// -// global::EnvDTE.CodeElements parameters = codeFunction.Parameters; -// -// Assert.AreEqual(0, parameters.Count); -// } -// -// [Test] -// public void Parameters_MethodHasOneParameter_ReturnsOneCodeParameter2() -// { -// AddParameterToMethod("test"); -// CreatePublicFunction("MyClass.MyMethod"); -// -// CodeParameter2 parameter = codeFunction.Parameters.FirstCodeParameter2OrDefault(); -// -// Assert.AreEqual("test", parameter.Name); -// } -// -// [Test] -// public void Parameters_MethodHasOneStringParameter_ReturnsOneCodeParameterWithStringType() -// { -// AddParameterToMethod("System.String", "test"); -// CreatePublicFunction("MyClass.MyMethod"); -// -// CodeParameter parameter = codeFunction.Parameters.FirstCodeParameterOrDefault(); -// -// Assert.AreEqual("System.String", parameter.Type.AsFullName); -// } -// -// [Test] -// public void Parameters_MethodHasOneStringParameter_CreatesCodeParameterWithProjectContent() -// { -// AddParameterToMethod("System.String", "test"); -// CreatePublicFunction("MyClass.MyMethod"); -// -// CodeParameter parameter = codeFunction.Parameters.FirstCodeParameterOrDefault(); -// -// Assert.AreEqual("string", parameter.Type.AsString); -// } -// -// [Test] -// public void Parameters_MethodHasOneStringParameter_CreatesCodeParameterWithCodeTypeRefThatHasParameterAsParent() -// { -// AddParameterToMethod("System.String", "test"); -// CreatePublicFunction("MyClass.MyMethod"); -// -// CodeParameter parameter = codeFunction.Parameters.FirstCodeParameterOrDefault(); -// -// Assert.AreEqual(parameter, parameter.Type.Parent); -// } -// -// [Test] -// public void Type_MethodReturnsString_TypeRefHasSystemStringAsFullName() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// AddReturnTypeToMethod("System.String"); -// -// global::EnvDTE.CodeTypeRef2 typeRef = codeFunction.Type; -// -// Assert.AreEqual("System.String", typeRef.AsFullName); -// } -// -// [Test] -// public void Type_MethodReturnsString_TypeRefUsesProjectContentFromMethod() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// AddReturnTypeToMethod("System.String"); -// -// global::EnvDTE.CodeTypeRef2 typeRef = codeFunction.Type; -// -// Assert.AreEqual("string", typeRef.AsString); -// } -// -// [Test] -// public void Type_MethodReturnsString_TypeRefParentIsCodeFunction() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// AddReturnTypeToMethod("System.String"); -// -// global::EnvDTE.CodeTypeRef2 typeRef = codeFunction.Type; -// -// Assert.AreEqual(codeFunction, typeRef.Parent); -// } -// -// [Test] -// public void FunctionKind_ClassMethod_ReturnsFunctionKind() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// -// global::EnvDTE.vsCMFunction kind = codeFunction.FunctionKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMFunction.vsCMFunctionFunction, kind); -// } -// -// [Test] -// public void FunctionKind_ClassConstructor_ReturnsConstructorKind() -// { -// CreatePublicConstructor("MyClass.MyClass"); -// -// global::EnvDTE.vsCMFunction kind = codeFunction.FunctionKind; -// -// Assert.AreEqual(global::EnvDTE.vsCMFunction.vsCMFunctionConstructor, kind); -// } -// -// [Test] -// public void IsShared_StaticMethod_ReturnsTrue() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// MakeMethodStatic(); -// -// bool shared = codeFunction.IsShared; -// -// Assert.IsTrue(shared); -// } -// -// [Test] -// public void IsShared_MethodIsNotStatic_ReturnsFalse() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// -// bool shared = codeFunction.IsShared; -// -// Assert.IsFalse(shared); -// } -// -// [Test] -// public void MustImplement_AbstractMethod_ReturnsTrue() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// MakeMethodAbstract(); -// -// bool mustImplement = codeFunction.MustImplement; -// -// Assert.IsTrue(mustImplement); -// } -// -// [Test] -// public void MustImplement_MethodIsNotAbstract_ReturnsFalse() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// -// bool mustImplement = codeFunction.MustImplement; -// -// Assert.IsFalse(mustImplement); -// } -// -// [Test] -// public void CanOverride_MethodIsOverridable_ReturnsTrue() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// MakeMethodOverridable(); -// -// bool canOverride = codeFunction.CanOverride; -// -// Assert.IsTrue(canOverride); -// } -// -// [Test] -// public void CanOverride_MethodIsNotAbstractOrVirtual_ReturnsFalse() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// -// bool canOverride = codeFunction.CanOverride; -// -// Assert.IsFalse(canOverride); -// } -// -// [Test] -// public void Attributes_MethodHasOneAttribute_ReturnsOneAttribute() -// { -// CreatePublicFunction("MyClass.MyFunction"); -// AddMethodAttribute("System.ObsoleteAttribute"); -// -// global::EnvDTE.CodeElements attributes = codeFunction.Attributes; -// -// CodeAttribute2 attribute = attributes.FirstCodeAttribute2OrDefault(); -// Assert.AreEqual(1, attributes.Count); -// Assert.AreEqual("System.ObsoleteAttribute", attribute.FullName); -// } + + void CreateFunction(string code) + { + AddCodeFile("class.cs", code); + + IMethod method = assemblyModel + .TopLevelTypeDefinitions + .First() + .Members + .First() + .Resolve() as IMethod; + + codeFunction = new CodeFunction(codeModelContext, method); + } + + [Test] + public void Access_PublicFunction_ReturnsPublic() + { + CreateFunction( + "public class Class1 {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.vsCMAccess access = codeFunction.Access; + + Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPublic, access); + } + + [Test] + public void Access_PrivateFunction_ReturnsPrivate() + { + CreateFunction( + "public class Class1 {\r\n" + + " private void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.vsCMAccess access = codeFunction.Access; + + Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPrivate, access); + } + + [Test] + public void GetStartPoint_FunctionStartsAtColumnOne_ReturnsPointWithOffsetOne() + { + CreateFunction( + "public class Class1 {\r\n" + + "public void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.TextPoint point = codeFunction.GetStartPoint(); + + int offset = point.LineCharOffset; + Assert.AreEqual(1, offset); + } + + [Test] + public void GetStartPoint_FunctionStartsAtLine2_ReturnsPointWithLine2() + { + CreateFunction( + "public class Class1 {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.TextPoint point = codeFunction.GetStartPoint(); + int line = point.Line; + + Assert.AreEqual(2, line); + } + + [Test] + public void GetEndPoint_FunctionBodyEndsAtColumnTwo_ReturnsPointWithOffsetTwo() + { + CreateFunction( + "public class Class1 {\r\n" + + " public void MyFunction() {\r\n" + + "}\r\n" + + "}"); + + global::EnvDTE.TextPoint point = codeFunction.GetEndPoint(); + int offset = point.LineCharOffset; + + Assert.AreEqual(2, offset); + } + + [Test] + public void GetEndPoint_FunctionBodyEndsAtLine4_ReturnsPointWithLine4() + { + CreateFunction( + "public class Class1 {\r\n" + + " public void MyFunction()\r\n" + + " {\r\n" + + " }\r\n" + + "}"); + + global::EnvDTE.TextPoint point = codeFunction.GetEndPoint(); + int line = point.Line; + + Assert.AreEqual(4, line); + } + + [Test] + public void Kind_PublicFunction_ReturnsFunction() + { + CreateFunction( + "public class Class1 {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.vsCMElement kind = codeFunction.Kind; + + Assert.AreEqual(global::EnvDTE.vsCMElement.vsCMElementFunction, kind); + } + + [Test] + public void GetEndPoint_InterfaceMethod_ReturnsMethodsDeclarationRegionEndNotBodyRegionEnd() + { + CreateFunction( + "public interface Foo {\r\n" + + " void Bar();\r\n" + + "}"); + + global::EnvDTE.TextPoint point = codeFunction.GetEndPoint(); + + Assert.AreEqual(2, point.Line); + Assert.AreEqual(16, point.LineCharOffset); + } + + [Test] + public void Parameters_MethodHasNoParameters_ReturnsEmptyListOfItems() + { + CreateFunction( + "public class Class1 {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.CodeElements parameters = codeFunction.Parameters; + + Assert.AreEqual(0, parameters.Count); + } + + [Test] + public void Parameters_MethodHasOneParameter_ReturnsOneCodeParameter2() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyMethod(int test) {}\r\n" + + "}"); + + CodeParameter2 parameter = codeFunction.Parameters.FirstCodeParameter2OrDefault(); + + Assert.AreEqual("test", parameter.Name); + } + + [Test] + public void Parameters_MethodHasOneStringParameter_ReturnsOneCodeParameterWithStringType() + { + CreateFunction( + "using System;\r\n" + + "public class MyClass {\r\n" + + " public void MyMethod(string test) {}\r\n" + + "}"); + + CodeParameter parameter = codeFunction.Parameters.FirstCodeParameterOrDefault(); + + Assert.AreEqual("System.String", parameter.Type.AsFullName); + Assert.AreEqual("string", parameter.Type.AsString); + } + + [Test] + public void Parameters_MethodHasOneStringParameter_CreatesCodeParameterWithContext() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyMethod(System.String test) {}\r\n" + + "}"); + + CodeParameter parameter = codeFunction.Parameters.FirstCodeParameterOrDefault(); + global::EnvDTE.TextPoint textPoint = parameter.Type.CodeType.GetStartPoint(); + + Assert.IsNotNull(textPoint); + } + + [Test] + public void Parameters_MethodHasOneStringParameter_CreatesCodeParameterWithCodeTypeRefThatHasParameterAsParent() + { + CreateFunction( + "using System;\r\n" + + "public class MyClass {\r\n" + + " public void MyMethod(string test) {}\r\n" + + "}"); + + CodeParameter parameter = codeFunction.Parameters.FirstCodeParameterOrDefault(); + + Assert.AreEqual(parameter, parameter.Type.Parent); + } + + [Test] + public void Type_MethodReturnsString_TypeRefHasSystemStringAsFullName() + { + CreateFunction( + "using System;\r\n" + + "public class MyClass {\r\n" + + " public string MyMethod() {}\r\n" + + "}"); + + global::EnvDTE.CodeTypeRef2 typeRef = codeFunction.Type; + + Assert.AreEqual("System.String", typeRef.AsFullName); + Assert.AreEqual("string", typeRef.AsString); + } + + [Test] + public void Type_MethodReturnsString_TypeRefUsesProjectContentFromMethod() + { + CreateFunction( + "using System;\r\n" + + "public class MyClass {\r\n" + + " public string MyMethod() {}\r\n" + + "}"); + + global::EnvDTE.CodeTypeRef2 typeRef = codeFunction.Type; + global::EnvDTE.TextPoint textPoint = typeRef.CodeType.GetStartPoint(); + + Assert.IsNotNull(textPoint); + } + + [Test] + public void Type_MethodReturnsString_TypeRefParentIsCodeFunction() + { + CreateFunction( + "using System;\r\n" + + "public class MyClass {\r\n" + + " public string MyMethod() {}\r\n" + + "}"); + + global::EnvDTE.CodeTypeRef2 typeRef = codeFunction.Type; + + Assert.AreEqual(codeFunction, typeRef.Parent); + } + + [Test] + public void FunctionKind_ClassMethod_ReturnsFunctionKind() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyMethod() {}\r\n" + + "}"); + + global::EnvDTE.vsCMFunction kind = codeFunction.FunctionKind; + + Assert.AreEqual(global::EnvDTE.vsCMFunction.vsCMFunctionFunction, kind); + } + + [Test] + public void FunctionKind_ClassConstructor_ReturnsConstructorKind() + { + CreateFunction( + "public class MyClass {\r\n" + + " public MyClass() {}\r\n" + + "}"); + + global::EnvDTE.vsCMFunction kind = codeFunction.FunctionKind; + + Assert.AreEqual(global::EnvDTE.vsCMFunction.vsCMFunctionConstructor, kind); + } + + [Test] + public void IsShared_StaticMethod_ReturnsTrue() + { + CreateFunction( + "public class MyClass {\r\n" + + " public static void MyFunction() {}\r\n" + + "}"); + + bool shared = codeFunction.IsShared; + + Assert.IsTrue(shared); + } + + [Test] + public void IsShared_MethodIsNotStatic_ReturnsFalse() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + bool shared = codeFunction.IsShared; + + Assert.IsFalse(shared); + } + + [Test] + public void MustImplement_AbstractMethod_ReturnsTrue() + { + CreateFunction( + "public class MyClass {\r\n" + + " public abstract void MyFunction();\r\n" + + "}"); + + bool mustImplement = codeFunction.MustImplement; + + Assert.IsTrue(mustImplement); + } + + [Test] + public void MustImplement_MethodIsNotAbstract_ReturnsFalse() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + bool mustImplement = codeFunction.MustImplement; + + Assert.IsFalse(mustImplement); + } + + [Test] + public void CanOverride_MethodIsOverridable_ReturnsTrue() + { + CreateFunction( + "public class MyClass {\r\n" + + " public virtual void MyFunction() {}\r\n" + + "}"); + + bool canOverride = codeFunction.CanOverride; + + Assert.IsTrue(canOverride); + } + + [Test] + public void CanOverride_MethodIsNotAbstractOrVirtual_ReturnsFalse() + { + CreateFunction( + "public class MyClass {\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + bool canOverride = codeFunction.CanOverride; + + Assert.IsFalse(canOverride); + } + + [Test] + public void Attributes_MethodHasOneAttribute_ReturnsOneAttribute() + { + CreateFunction( + "using System;\r\n" + + "public class MyClass {\r\n" + + " [Obsolete]\r\n" + + " public void MyFunction() {}\r\n" + + "}"); + + global::EnvDTE.CodeElements attributes = codeFunction.Attributes; + + CodeAttribute2 attribute = attributes.FirstCodeAttribute2OrDefault(); + Assert.AreEqual(1, attributes.Count); + Assert.AreEqual("System.ObsoleteAttribute", attribute.FullName); + } // // [Test] // public void CanOverride_SetToTrueForFunction_VirtualKeywordAddedToFunction() @@ -396,5 +402,5 @@ // // methodUpdater.AssertWasNotCalled(updater => updater.MakeMethodVirtual()); // } -// } -//} + } +} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/CompilationUnitHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/CompilationUnitHelper.cs deleted file mode 100644 index d4b964c1d4..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/CompilationUnitHelper.cs +++ /dev/null @@ -1,50 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.Generic; -//using ICSharpCode.SharpDevelop.Dom; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class CompilationUnitHelper -// { -// public ICompilationUnit CompilationUnit; -// public FakeCodeGenerator FakeCodeGenerator = new FakeCodeGenerator(); -// public List Classes = new List(); -// public UsingScopeHelper UsingScopeHelper = new UsingScopeHelper(); -// public ProjectContentHelper ProjectContentHelper = new ProjectContentHelper(); -// -// public CompilationUnitHelper() -// { -// CompilationUnit = MockRepository.GenerateStub(); -// LanguageProperties language = MockRepository.GenerateStub(StringComparer.InvariantCultureIgnoreCase); -// language.Stub(lang => lang.CodeGenerator).Return(FakeCodeGenerator); -// CompilationUnit.Stub(unit => unit.Language).Return(language); -// CompilationUnit.Stub(unit => unit.Classes).Return(Classes); -// CompilationUnit.Stub(unit => unit.UsingScope).Return(UsingScopeHelper.UsingScope); -// CompilationUnit.Stub(unit => unit.ProjectContent).Return(ProjectContentHelper.ProjectContent); -// } -// -// public void SetFileName(string fileName) -// { -// CompilationUnit.FileName = fileName; -// } -// -// public void AddClass(IClass c) -// { -// Classes.Add(c); -// } -// -// public void AddNamespace(string name) -// { -// UsingScopeHelper.AddNamespace(name); -// } -// -// public void AddNamespaceAlias(string alias, string namespaceName) -// { -// UsingScopeHelper.AddNamespaceAlias(alias, namespaceName); -// } -// } -//} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodHelper.cs deleted file mode 100644 index fca3779400..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodHelper.cs +++ /dev/null @@ -1,182 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.Generic; -//using ICSharpCode.SharpDevelop.Dom; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class MethodHelper : MethodOrPropertyHelper -// { -// public IMethod Method; -// public ProjectContentHelper ProjectContentHelper = new ProjectContentHelper(); -// -// /// -// /// Method name should include class prefix (e.g. "Class1.MyMethod") -// /// -// public void CreateMethod(string fullyQualifiedName) -// { -// Method = MockRepository.GenerateMock(); -// Method.Stub(m => m.ProjectContent).Return(ProjectContentHelper.ProjectContent); -// Method.Stub(m => m.FullyQualifiedName).Return(fullyQualifiedName); -// Method.Stub(m => m.Parameters).Return(parameters); -// } -// -// public void CreatePublicMethod(string name) -// { -// CreateMethod(name); -// Method.Stub(m => m.IsPublic).Return(true); -// } -// -// public void CreatePublicConstructor(string name) -// { -// CreatePublicMethod(name); -// Method.Stub(m => m.IsConstructor).Return(true); -// } -// -// public void CreatePrivateMethod(string name) -// { -// CreateMethod(name); -// Method.Stub(m => m.IsPublic).Return(false); -// Method.Stub(m => m.IsPrivate).Return(true); -// } -// -// public void FunctionStartsAtColumn(int column) -// { -// var region = new DomRegion(1, column); -// FunctionStartsAt(region); -// } -// -// public void FunctionStartsAt(DomRegion region) -// { -// Method.Stub(m => m.Region).Return(region); -// } -// -// public void FunctionStartsAtLine(int line) -// { -// var region = new DomRegion(line, 1); -// FunctionStartsAt(region); -// } -// -// public void FunctionBodyEndsAtColumn(int column) -// { -// var region = new DomRegion(1, 1, 1, column); -// FunctionBodyEndsAt(region); -// } -// -// void FunctionBodyEndsAt(DomRegion region) -// { -// Method.Stub(m => m.BodyRegion).Return(region); -// } -// -// public void FunctionBodyEndsAtLine(int line) -// { -// var region = new DomRegion(1, 1, line, 1); -// FunctionBodyEndsAt(region); -// } -// -// public void SetRegion(DomRegion region) -// { -// Method.Stub(m => m.Region).Return(region); -// } -// -// public void SetBodyRegion(DomRegion region) -// { -// Method.Stub(m => m.BodyRegion).Return(region); -// } -// -// public void SetCompilationUnitFileName(string fileName) -// { -// ICompilationUnit unit = MockRepository.GenerateStub(); -// unit.FileName = fileName; -// Method.Stub(m => m.CompilationUnit).Return(unit); -// } -// -// public void AddDeclaringTypeAsInterface(string name) -// { -// IClass declaringType = ProjectContentHelper.AddInterfaceToProjectContent(name); -// SetDeclaringType(declaringType); -// } -// -// public void SetDeclaringType(IClass declaringType) -// { -// Method.Stub(m => m.DeclaringType).Return(declaringType); -// } -// -// public void AddDeclaringType(string name) -// { -// IClass declaringType = ProjectContentHelper.AddClassToProjectContent(name); -// SetDeclaringType(declaringType); -// } -// -// public void AddReturnTypeToMethod(string type) -// { -// var returnTypeHelper = new ReturnTypeHelper(); -// returnTypeHelper.CreateReturnType(type); -// returnTypeHelper.AddDotNetName(type); -// -// Method.Stub(m => m.ReturnType).Return(returnTypeHelper.ReturnType); -// } -// -// public void MakeMethodStatic() -// { -// Method.Stub(m => m.IsStatic).Return(true); -// } -// -// public void MakeMethodAbstract() -// { -// Method.Stub(m => m.IsAbstract).Return(true); -// } -// -// public void MakeMethodVirtual() -// { -// Method.Stub(m => m.IsVirtual).Return(true); -// } -// -// public void AddAttributeToMethod(string attributeTypeName) -// { -// var attributeHelper = new AttributeHelper(); -// attributeHelper.CreateAttribute(attributeTypeName); -// attributeHelper.AddAttributeToMethod(Method); -// } -// -// public void MakeMethodOverride() -// { -// Method.Stub(m => m.IsOverride).Return(true); -// } -// -// public void MakeMethodSealed() -// { -// Method.Stub(m => m.IsSealed).Return(true); -// } -// -// public void MakeMethodNewOverride() -// { -// Method.Stub(m => m.IsNew).Return(true); -// } -// -// public void MakeMethodOverridable() -// { -// Method.Stub(m => m.IsOverridable).Return(true); -// } -// -// public void AddTypeParameter(string name) -// { -// var typeParameterHelper = new TypeParameterHelper(); -// typeParameterHelper.SetName(name); -// AddTypeParameters(typeParameterHelper.TypeParameterToList()); -// } -// -// public void AddTypeParameters(List typeParameters) -// { -// Method.Stub(m => m.TypeParameters).Return(typeParameters); -// } -// -// public void NoTypeParameters() -// { -// AddTypeParameters(new List()); -// } -// } -//} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodOrPropertyHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodOrPropertyHelper.cs deleted file mode 100644 index dd151973f2..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodOrPropertyHelper.cs +++ /dev/null @@ -1,33 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.Generic; -//using ICSharpCode.SharpDevelop.Dom; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class MethodOrPropertyHelper -// { -// public List parameters = new List(); -// -// public void AddParameter(string name) -// { -// AddParameter("System.String", name); -// } -// -// public void AddParameter(string type, string name) -// { -// IParameter parameter = MockRepository.GenerateStub(); -// parameter.Stub(p => p.Name).Return(name); -// -// var returnTypeHelper = new ReturnTypeHelper(); -// returnTypeHelper.CreateReturnType("System.String"); -// returnTypeHelper.AddDotNetName("System.String"); -// parameter.ReturnType = returnTypeHelper.ReturnType; -// -// parameters.Add(parameter); -// } -// } -//} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectContentHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectContentHelper.cs deleted file mode 100644 index c33933c701..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectContentHelper.cs +++ /dev/null @@ -1,239 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.Generic; -//using System.Linq; -// -//using ICSharpCode.SharpDevelop.Dom; -//using ICSharpCode.SharpDevelop.Project; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class ProjectContentHelper -// { -// public IProjectContent ProjectContent; -// public List NamespaceNames = new List(); -// -// public ProjectContentHelper() -// { -// ProjectContent = MockRepository.GenerateStub(); -// ProjectContent.Stub(pc => pc.NamespaceNames).Return(NamespaceNames); -// } -// -// public void SetProjectForProjectContent(object project) -// { -// ProjectContent.Stub(pc => pc.Project).Return(project); -// } -// -// public IClass AddClassToProjectContentAndCompletionEntries(string namespaceName, string className) -// { -// IClass fakeClass = AddClassToProjectContent(className); -// var namespaceContents = new List(); -// namespaceContents.Add(fakeClass); -// AddCompletionEntriesToNamespace(namespaceName, namespaceContents); -// -// return fakeClass; -// } -// -// public void AddCompletionEntriesToNamespace(string namespaceName, List namespaceContents) -// { -// ProjectContent.Stub(pc => pc.GetNamespaceContents(namespaceName)).Return(namespaceContents); -// } -// -// public void NoCompletionItemsInNamespace(string namespaceName) -// { -// AddCompletionEntriesToNamespace(namespaceName, new List()); -// } -// -// public IClass AddClassToProjectContent(string className) -// { -// IClass fakeClass = AddClassToProjectContentCommon(ProjectContent, className); -// SetClassType(fakeClass, ClassType.Class); -// return fakeClass; -// } -// -// public void SetClassType(IClass fakeClass, ClassType classType) -// { -// fakeClass.Stub(c => c.ClassType).Return(classType); -// } -// -// public void AddClassToDifferentProjectContent(string className) -// { -// IProjectContent differentProjectContent = MockRepository.GenerateStub(); -// AddClassToProjectContentCommon(differentProjectContent, className); -// } -// -// IClass AddClassToProjectContentCommon(IProjectContent projectContent, string className) -// { -// IClass fakeClass = MockRepository.GenerateMock(); -// ProjectContent.Stub(pc => pc.GetClass(className, 0)).Return(fakeClass); -// fakeClass.Stub(c => c.FullyQualifiedName).Return(className); -// fakeClass.Stub(c => c.ProjectContent).Return(projectContent); -// return fakeClass; -// } -// -// public IClass AddInterfaceToProjectContent(string interfaceName) -// { -// return AddInterfaceToProjectContent(ProjectContent, interfaceName); -// } -// -// public IClass AddInterfaceToDifferentProjectContent(string interfaceName) -// { -// IProjectContent projectContent = MockRepository.GenerateStub(); -// return AddInterfaceToProjectContent(projectContent, interfaceName); -// } -// -// public IClass AddInterfaceToProjectContent(IProjectContent projectContent, string interfaceName) -// { -// IClass fakeClass = AddClassToProjectContentCommon(projectContent, interfaceName); -// SetClassType(fakeClass, ClassType.Interface); -// return fakeClass; -// } -// -// public IClass AddInterfaceToProjectContentAndCompletionEntries(string namespaceName, string className) -// { -// IClass fakeClass = AddInterfaceToProjectContent(className); -// var namespaceContents = new List(); -// namespaceContents.Add(fakeClass); -// AddCompletionEntriesToNamespace(namespaceName, namespaceContents); -// -// return fakeClass; -// } -// -// public void AddNamespaceNameToProjectContent(string name) -// { -// NamespaceNames.Add(name); -// } -// -// public void NoCompletionEntriesForRootNamespace() -// { -// NoCompletionItemsInNamespace(String.Empty); -// } -// -// public void AddUnknownCompletionEntryTypeToNamespace(string namespaceName) -// { -// var unknownEntry = MockRepository.GenerateStub(); -// var namespaceContents = new List(); -// namespaceContents.Add(unknownEntry); -// AddCompletionEntriesToNamespace(namespaceName, namespaceContents); -// } -// -// public void AddNamespaceCompletionEntryInNamespace(string parentNamespaceName, string namespaceName) -// { -// AddNamespaceCompletionEntriesInNamespace(parentNamespaceName, new string[] { namespaceName }); -// } -// -// public void AddNamespaceCompletionEntriesInNamespace(string parentNamespaceName, params string[] childNamespaceNames) -// { -// List entries = childNamespaceNames -// .Select(name => new NamespaceEntry(name) as ICompletionEntry) -// .ToList(); -// AddCompletionEntriesToNamespace(parentNamespaceName, entries); -// } -// -// public void AddClassCompletionEntriesInDifferentProjectContent(string namespaceName, string className) -// { -// IProjectContent differentProjectContent = MockRepository.GenerateStub(); -// AddClassToCompletionEntries(differentProjectContent, namespaceName, className); -// } -// -// public void AddClassToCompletionEntries(string namespaceName, string className) -// { -// AddClassToCompletionEntries(ProjectContent, namespaceName, className); -// } -// -// void AddClassToCompletionEntries(IProjectContent projectContent, string namespaceName, string className) -// { -// IClass fakeClass = MockRepository.GenerateStub(); -// fakeClass.Stub(c => c.ProjectContent).Return(projectContent); -// var entries = new List(); -// entries.Add(fakeClass); -// AddCompletionEntriesToNamespace(namespaceName, entries); -// } -// -// public void ProjectContentIsForCSharpProject() -// { -// TestableProject project = ProjectHelper.CreateTestProject(); -// project.FileName = @"c:\projects\myproject.csproj"; -// ProjectContent.Stub(pc => pc.Language).Return(LanguageProperties.CSharp); -// SetProjectForProjectContent(project); -// } -// -// public void ProjectContentIsForVisualBasicProject() -// { -// TestableProject project = ProjectHelper.CreateTestProject(); -// project.FileName = @"c:\projects\myproject.vbproj"; -// ProjectContent.Stub(pc => pc.Language).Return(LanguageProperties.VBNet); -// SetProjectForProjectContent(project); -// } -// -// public IClass AddPublicClassToProjectContent(string name) -// { -// IClass fakeClass = AddClassToProjectContent(name); -// MakeClassPublic(fakeClass); -// return fakeClass; -// } -// -// public IClass AddPrivateClassToProjectContent(string name) -// { -// IClass fakeClass = AddClassToProjectContent(name); -// MakeClassPrivate(fakeClass); -// return fakeClass; -// } -// -// public IClass AddPublicStructToProjectContent(string name) -// { -// IClass fakeStruct = AddStructToProjectContent(name); -// MakeClassPublic(fakeStruct); -// return fakeStruct; -// } -// -// public IClass AddStructToProjectContent(string name) -// { -// IClass fakeStruct = AddClassToProjectContentCommon(ProjectContent, name); -// SetClassType(fakeStruct, ClassType.Struct); -// return fakeStruct; -// } -// -// public IClass AddPrivateStructToProjectContent(string name) -// { -// IClass fakeStruct = AddStructToProjectContent(name); -// MakeClassPrivate(fakeStruct); -// return fakeStruct; -// } -// -// public IClass AddPublicDelegateToProjectContent(string name) -// { -// IClass fakeDelegate = AddDelegateToProjectContent(name); -// MakeClassPublic(fakeDelegate); -// return fakeDelegate; -// } -// -// public IClass AddDelegateToProjectContent(string name) -// { -// IClass fakeDelegate = AddClassToProjectContentCommon(ProjectContent, name); -// SetClassType(fakeDelegate, ClassType.Delegate); -// return fakeDelegate; -// } -// -// public void MakeClassPublic(IClass fakeClass) -// { -// fakeClass.Stub(c => c.IsPublic).Return(true); -// } -// -// public void MakeClassPrivate(IClass fakeClass) -// { -// fakeClass.Stub(c => c.IsPublic).Return(false); -// fakeClass.Stub(c => c.IsPrivate).Return(true); -// } -// -// public IClass AddPrivateDelegateToProjectContent(string name) -// { -// IClass fakeDelegate = AddDelegateToProjectContent(name); -// MakeClassPrivate(fakeDelegate); -// return fakeDelegate; -// } -// } -//} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ReturnTypeHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ReturnTypeHelper.cs deleted file mode 100644 index db1b7bc3d8..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ReturnTypeHelper.cs +++ /dev/null @@ -1,41 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using ICSharpCode.SharpDevelop.Dom; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class ReturnTypeHelper -// { -// public IReturnType ReturnType; -// public ProjectContentHelper ProjectContentHelper = new ProjectContentHelper(); -// -// public void CreateReturnType(string fullyQualifiedName) -// { -// ReturnType = MockRepository.GenerateStub(); -// ReturnType.Stub(b => b.FullyQualifiedName).Return(fullyQualifiedName); -// } -// -// public void AddDotNetName(string name) -// { -// ReturnType.Stub(t => t.DotNetName).Return(name); -// } -// -// public void AddShortName(string name) -// { -// ReturnType.Stub(t => t.Name).Return(name); -// } -// -// public void AddUnderlyingClass(IClass c) -// { -// ReturnType.Stub(t => t.GetUnderlyingClass()).Return(c); -// } -// -// public void MakeReferenceType() -// { -// ReturnType.Stub(t => t.IsReferenceType).Return(true); -// } -// } -//} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TypeParameterHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TypeParameterHelper.cs deleted file mode 100644 index 1fc7ac877d..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TypeParameterHelper.cs +++ /dev/null @@ -1,32 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.Generic; -//using ICSharpCode.SharpDevelop.Dom; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class TypeParameterHelper -// { -// public ITypeParameter TypeParameter; -// -// public TypeParameterHelper() -// { -// TypeParameter = MockRepository.GenerateMock(); -// } -// -// public void SetName(string name) -// { -// TypeParameter.Stub(tp => tp.Name); -// } -// -// public List TypeParameterToList() -// { -// var parameters = new List(); -// parameters.Add(TypeParameter); -// return parameters; -// } -// } -//} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingHelper.cs deleted file mode 100644 index 9bb31aa3ec..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingHelper.cs +++ /dev/null @@ -1,44 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.Generic; -//using ICSharpCode.SharpDevelop.Dom; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class UsingHelper -// { -// public IUsing Using; -// public List Namespaces = new List(); -// -// public UsingHelper() -// { -// Using = MockRepository.GenerateStub(); -// Using.Stub(u => u.Usings).Return(Namespaces); -// } -// -// public void AddNamespace(string name) -// { -// Namespaces.Add(name); -// } -// -// public void AddNamespaceAlias(string alias, string namespaceName) -// { -// Dictionary aliases = CreateAliasDictionary(alias, namespaceName); -// Using.Stub(u => u.HasAliases).Return(true); -// Using.Stub(u => u.Aliases).Return(aliases); -// } -// -// Dictionary CreateAliasDictionary(string alias, string namespaceName) -// { -// var helper = new ReturnTypeHelper(); -// helper.CreateReturnType(namespaceName); -// helper.AddDotNetName(namespaceName); -// var aliases = new Dictionary(); -// aliases.Add(alias, helper.ReturnType); -// return aliases; -// } -// } -//} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingScopeHelper.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingScopeHelper.cs deleted file mode 100644 index 6f36c9b1c8..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingScopeHelper.cs +++ /dev/null @@ -1,46 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) -// -//using System; -//using System.Collections.Generic; -//using ICSharpCode.SharpDevelop.Dom; -//using Rhino.Mocks; -// -//namespace PackageManagement.Tests.Helpers -//{ -// public class UsingScopeHelper -// { -// public IUsingScope UsingScope; -// public List Usings = new List(); -// -// public UsingScopeHelper() -// { -// UsingScope = MockRepository.GenerateStub(); -// UsingScope.Stub(scope => scope.Usings).Return(Usings); -// } -// -// public void AddNamespace(string name) -// { -// var usingHelper = new UsingHelper(); -// usingHelper.AddNamespace(name); -// Usings.Add(usingHelper.Using); -// } -// -// IUsing CreateUsingWithNamespaces(params string[] names) -// { -// return null; -// } -// -// public void AddNamespaceAlias(string alias, string namespaceName) -// { -// var usingHelper = new UsingHelper(); -// usingHelper.AddNamespaceAlias(alias, namespaceName); -// Usings.Add(usingHelper.Using); -// } -// -// public void SetNamespaceName(string namespaceName) -// { -// UsingScope.Stub(u => u.NamespaceName).Return(namespaceName); -// } -// } -//}