Browse Source

Update EnvDTE.CodeFunction tests.

pull/375/head
Matt Ward 12 years ago
parent
commit
dea25f9bbf
  1. 6
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeFunction.cs
  2. 8
      src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
  3. 266
      src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunction2Tests.cs
  4. 756
      src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunctionTests.cs
  5. 50
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/CompilationUnitHelper.cs
  6. 182
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodHelper.cs
  7. 33
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodOrPropertyHelper.cs
  8. 239
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectContentHelper.cs
  9. 41
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ReturnTypeHelper.cs
  10. 32
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TypeParameterHelper.cs
  11. 44
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingHelper.cs
  12. 46
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingScopeHelper.cs

6
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeFunction.cs

@ -57,9 +57,9 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -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);
// }
}
}

8
src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj

@ -114,7 +114,6 @@ @@ -114,7 +114,6 @@
<Compile Include="Src\EnvDTE\SolutionPropertyTests.cs" />
<Compile Include="Src\EnvDTE\SolutionTests.cs" />
<Compile Include="Src\Helpers\CodeElementsExtensions.cs" />
<Compile Include="Src\Helpers\CompilationUnitHelper.cs" />
<Compile Include="Src\Helpers\ExceptionThrowingPackageActionRunner.cs" />
<Compile Include="Src\Helpers\ExceptionThrowingProcessPackageAction.cs" />
<Compile Include="Src\Helpers\FakeCodeGenerator.cs" />
@ -123,12 +122,8 @@ @@ -123,12 +122,8 @@
<Compile Include="Src\Helpers\FakeSolutionPackageRepositoryFactory.cs" />
<Compile Include="Src\Helpers\FakeUpdatePackageActions.cs" />
<Compile Include="Src\Helpers\FakeUpdatePackageActionsFactory.cs" />
<Compile Include="Src\Helpers\MethodHelper.cs" />
<Compile Include="Src\Helpers\MethodOrPropertyHelper.cs" />
<Compile Include="Src\Helpers\PackageOperationHelper.cs" />
<Compile Include="Src\Helpers\ProjectContentHelper.cs" />
<Compile Include="Src\Helpers\PropertiesHelper.cs" />
<Compile Include="Src\Helpers\ReturnTypeHelper.cs" />
<Compile Include="Src\Helpers\SelectedProjectCollectionAssert.cs" />
<Compile Include="Src\Helpers\SolutionHelper.cs" />
<Compile Include="Src\Helpers\TestableInstalledPackageViewModel.cs" />
@ -139,9 +134,6 @@ @@ -139,9 +134,6 @@
<Compile Include="Src\Helpers\TestableUpdatePackagesAction.cs" />
<Compile Include="Src\Helpers\TestableUpdateSolutionPackagesAction.cs" />
<Compile Include="Src\Helpers\TestPackageHelper.cs" />
<Compile Include="Src\Helpers\TypeParameterHelper.cs" />
<Compile Include="Src\Helpers\UsingHelper.cs" />
<Compile Include="Src\Helpers\UsingScopeHelper.cs" />
<Compile Include="Src\InstalledPackageViewModelTests.cs" />
<Compile Include="Src\IPackageExtensionsTests.cs" />
<Compile Include="Src\ManagePackagesCommandTests.cs" />

266
src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunction2Tests.cs

@ -1,131 +1,135 @@ @@ -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<TResult>() {}\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);
}
}
}

756
src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeFunctionTests.cs

@ -1,381 +1,387 @@ @@ -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<IVirtualMethodUpdater>();
// 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 @@ @@ -396,5 +402,5 @@
//
// methodUpdater.AssertWasNotCalled(updater => updater.MakeMethodVirtual());
// }
// }
//}
}
}

50
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/CompilationUnitHelper.cs

@ -1,50 +0,0 @@ @@ -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<IClass> Classes = new List<IClass>();
// public UsingScopeHelper UsingScopeHelper = new UsingScopeHelper();
// public ProjectContentHelper ProjectContentHelper = new ProjectContentHelper();
//
// public CompilationUnitHelper()
// {
// CompilationUnit = MockRepository.GenerateStub<ICompilationUnit>();
// LanguageProperties language = MockRepository.GenerateStub<LanguageProperties>(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);
// }
// }
//}

182
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodHelper.cs

@ -1,182 +0,0 @@ @@ -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();
//
// /// <summary>
// /// Method name should include class prefix (e.g. "Class1.MyMethod")
// /// </summary>
// public void CreateMethod(string fullyQualifiedName)
// {
// Method = MockRepository.GenerateMock<IMethod, IEntity>();
// 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<ICompilationUnit>();
// 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<ITypeParameter> typeParameters)
// {
// Method.Stub(m => m.TypeParameters).Return(typeParameters);
// }
//
// public void NoTypeParameters()
// {
// AddTypeParameters(new List<ITypeParameter>());
// }
// }
//}

33
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/MethodOrPropertyHelper.cs

@ -1,33 +0,0 @@ @@ -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<IParameter> parameters = new List<IParameter>();
//
// public void AddParameter(string name)
// {
// AddParameter("System.String", name);
// }
//
// public void AddParameter(string type, string name)
// {
// IParameter parameter = MockRepository.GenerateStub<IParameter>();
// 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);
// }
// }
//}

239
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ProjectContentHelper.cs

@ -1,239 +0,0 @@ @@ -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<string> NamespaceNames = new List<string>();
//
// public ProjectContentHelper()
// {
// ProjectContent = MockRepository.GenerateStub<IProjectContent>();
// 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<ICompletionEntry>();
// namespaceContents.Add(fakeClass);
// AddCompletionEntriesToNamespace(namespaceName, namespaceContents);
//
// return fakeClass;
// }
//
// public void AddCompletionEntriesToNamespace(string namespaceName, List<ICompletionEntry> namespaceContents)
// {
// ProjectContent.Stub(pc => pc.GetNamespaceContents(namespaceName)).Return(namespaceContents);
// }
//
// public void NoCompletionItemsInNamespace(string namespaceName)
// {
// AddCompletionEntriesToNamespace(namespaceName, new List<ICompletionEntry>());
// }
//
// 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<IProjectContent>();
// AddClassToProjectContentCommon(differentProjectContent, className);
// }
//
// IClass AddClassToProjectContentCommon(IProjectContent projectContent, string className)
// {
// IClass fakeClass = MockRepository.GenerateMock<IClass, IEntity>();
// 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<IProjectContent>();
// 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<ICompletionEntry>();
// 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<ICompletionEntry>();
// var namespaceContents = new List<ICompletionEntry>();
// 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<ICompletionEntry> entries = childNamespaceNames
// .Select(name => new NamespaceEntry(name) as ICompletionEntry)
// .ToList();
// AddCompletionEntriesToNamespace(parentNamespaceName, entries);
// }
//
// public void AddClassCompletionEntriesInDifferentProjectContent(string namespaceName, string className)
// {
// IProjectContent differentProjectContent = MockRepository.GenerateStub<IProjectContent>();
// 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<IClass>();
// fakeClass.Stub(c => c.ProjectContent).Return(projectContent);
// var entries = new List<ICompletionEntry>();
// 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;
// }
// }
//}

41
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ReturnTypeHelper.cs

@ -1,41 +0,0 @@ @@ -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<IReturnType>();
// 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);
// }
// }
//}

32
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TypeParameterHelper.cs

@ -1,32 +0,0 @@ @@ -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<ITypeParameter>();
// }
//
// public void SetName(string name)
// {
// TypeParameter.Stub(tp => tp.Name);
// }
//
// public List<ITypeParameter> TypeParameterToList()
// {
// var parameters = new List<ITypeParameter>();
// parameters.Add(TypeParameter);
// return parameters;
// }
// }
//}

44
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingHelper.cs

@ -1,44 +0,0 @@ @@ -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<string> Namespaces = new List<string>();
//
// public UsingHelper()
// {
// Using = MockRepository.GenerateStub<IUsing>();
// Using.Stub(u => u.Usings).Return(Namespaces);
// }
//
// public void AddNamespace(string name)
// {
// Namespaces.Add(name);
// }
//
// public void AddNamespaceAlias(string alias, string namespaceName)
// {
// Dictionary<string, IReturnType> aliases = CreateAliasDictionary(alias, namespaceName);
// Using.Stub(u => u.HasAliases).Return(true);
// Using.Stub(u => u.Aliases).Return(aliases);
// }
//
// Dictionary<string, IReturnType> CreateAliasDictionary(string alias, string namespaceName)
// {
// var helper = new ReturnTypeHelper();
// helper.CreateReturnType(namespaceName);
// helper.AddDotNetName(namespaceName);
// var aliases = new Dictionary<string, IReturnType>();
// aliases.Add(alias, helper.ReturnType);
// return aliases;
// }
// }
//}

46
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/UsingScopeHelper.cs

@ -1,46 +0,0 @@ @@ -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<IUsing> Usings = new List<IUsing>();
//
// public UsingScopeHelper()
// {
// UsingScope = MockRepository.GenerateStub<IUsingScope>();
// 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);
// }
// }
//}
Loading…
Cancel
Save