19 changed files with 429 additions and 153 deletions
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.PackageManagement.EnvDTE |
||||
{ |
||||
public class CodeTypeMembers : CodeElementsList |
||||
{ |
||||
IProjectContent projectContent; |
||||
IClass c; |
||||
|
||||
public CodeTypeMembers(IProjectContent projectContent, IClass c) |
||||
{ |
||||
this.projectContent = projectContent; |
||||
this.c = c; |
||||
AddMembers(); |
||||
} |
||||
|
||||
void AddMembers() |
||||
{ |
||||
foreach (IProperty property in c.Properties) { |
||||
AddProperty(property); |
||||
} |
||||
foreach (IField field in c.Fields) { |
||||
AddField(field); |
||||
} |
||||
foreach (IMethod method in c.Methods) { |
||||
AddMethod(method); |
||||
} |
||||
} |
||||
|
||||
void AddMethod(IMethod method) |
||||
{ |
||||
AddCodeElement(new CodeFunction(method)); |
||||
} |
||||
|
||||
void AddField(IField field) |
||||
{ |
||||
AddCodeElement(new CodeVariable(field)); |
||||
} |
||||
|
||||
void AddProperty(IProperty property) |
||||
{ |
||||
AddCodeElement(new CodeProperty2(property)); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
// 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 ClassHelper |
||||
{ |
||||
public IClass Class; |
||||
public ProjectContentHelper ProjectContentHelper = new ProjectContentHelper(); |
||||
|
||||
List<IMethod> methods = new List<IMethod>(); |
||||
List<IProperty> properties = new List<IProperty>(); |
||||
List<IField> fields = new List<IField>(); |
||||
|
||||
public void CreateClass(string name) |
||||
{ |
||||
Class = ProjectContentHelper.AddClassToProjectContent(name); |
||||
InitializeClassCommon(); |
||||
} |
||||
|
||||
void InitializeClassCommon() |
||||
{ |
||||
Class.Stub(c => c.Methods).Return(methods); |
||||
Class.Stub(c => c.Properties).Return(properties); |
||||
Class.Stub(c => c.Fields).Return(fields); |
||||
} |
||||
|
||||
public void AddAttributeToClass(string name) |
||||
{ |
||||
var attributeHelper = new AttributeHelper(); |
||||
attributeHelper.CreateAttribute(name); |
||||
attributeHelper.AddAttributeToClass(Class); |
||||
} |
||||
|
||||
public void CreatePublicClass(string name) |
||||
{ |
||||
Class = ProjectContentHelper.AddPublicClassToProjectContent(name); |
||||
InitializeClassCommon(); |
||||
} |
||||
|
||||
public void CreatePrivateClass(string name) |
||||
{ |
||||
Class = ProjectContentHelper.AddPrivateClassToProjectContent(name); |
||||
InitializeClassCommon(); |
||||
} |
||||
|
||||
public void AddInterfaceToClassBaseTypes(string interfaceFullName, string dotNetName) |
||||
{ |
||||
IClass interfaceClass = ProjectContentHelper.AddInterfaceToProjectContent(interfaceFullName); |
||||
AddClassToClassBaseTypes(interfaceClass, interfaceFullName, dotNetName); |
||||
} |
||||
|
||||
public void AddClassToClassBaseTypes(IClass baseTypeClass, string baseTypeFullName, string baseTypeDotNetName) |
||||
{ |
||||
IReturnType baseType = CreateBaseType(baseTypeClass, baseTypeFullName, baseTypeDotNetName); |
||||
var baseTypes = new List<IReturnType>(); |
||||
baseTypes.Add(baseType); |
||||
|
||||
Class.Stub(c => c.BaseTypes).Return(baseTypes); |
||||
} |
||||
|
||||
IReturnType CreateBaseType(IClass baseTypeClass, string baseTypeFullName, string baseTypeDotNetName) |
||||
{ |
||||
IReturnType baseType = MockRepository.GenerateStub<IReturnType>(); |
||||
baseType.Stub(b => b.GetUnderlyingClass()).Return(baseTypeClass); |
||||
baseType.Stub(b => b.FullyQualifiedName).Return(baseTypeFullName); |
||||
baseType.Stub(b => b.DotNetName).Return(baseTypeDotNetName); |
||||
return baseType; |
||||
} |
||||
|
||||
public void AddClassToClassBaseTypes(string fullName) |
||||
{ |
||||
IClass baseTypeClass = ProjectContentHelper.AddClassToProjectContent(fullName); |
||||
AddClassToClassBaseTypes(baseTypeClass, fullName, fullName); |
||||
} |
||||
|
||||
public void AddBaseTypeToClass(string fullName) |
||||
{ |
||||
IClass baseTypeClass = ProjectContentHelper.AddClassToProjectContent(fullName); |
||||
IReturnType baseType = CreateBaseType(baseTypeClass, fullName, fullName); |
||||
|
||||
Class.Stub(c => c.BaseType).Return(baseType); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Name should include the class prefix (e.g. "Class1.MyMethod");
|
||||
/// </summary>
|
||||
public void AddMethodToClass(string fullyQualifiedName) |
||||
{ |
||||
var helper = new MethodHelper(); |
||||
helper.ProjectContentHelper = ProjectContentHelper; |
||||
helper.CreateMethod(fullyQualifiedName); |
||||
methods.Add(helper.Method); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Name should include the class prefix (e.g. "Class1.MyProperty");
|
||||
/// </summary>
|
||||
public void AddPropertyToClass(string fullyQualifiedName) |
||||
{ |
||||
var helper = new PropertyHelper(); |
||||
helper.ProjectContentHelper = ProjectContentHelper; |
||||
helper.CreateProperty(fullyQualifiedName); |
||||
|
||||
properties.Add(helper.Property); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Name should include the class prefix (e.g. "Class1.MyField");
|
||||
/// </summary>
|
||||
public void AddFieldToClass(string fullyQualifiedName) |
||||
{ |
||||
var helper = new FieldHelper(); |
||||
helper.ProjectContentHelper = ProjectContentHelper; |
||||
helper.CreateField(fullyQualifiedName); |
||||
|
||||
fields.Add(helper.Field); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// 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 FieldHelper |
||||
{ |
||||
public IField Field; |
||||
public ProjectContentHelper ProjectContentHelper = new ProjectContentHelper(); |
||||
|
||||
/// <summary>
|
||||
/// Field name should include the class prefix (e.g. "Class1.MyField")
|
||||
/// </summary>
|
||||
public void CreateField(string fullyQualifiedName) |
||||
{ |
||||
Field = MockRepository.GenerateMock<IField, IEntity>(); |
||||
Field.Stub(f => f.ProjectContent).Return(ProjectContentHelper.FakeProjectContent); |
||||
Field.Stub(f => f.FullyQualifiedName).Return(fullyQualifiedName); |
||||
} |
||||
|
||||
public void CreatePublicField(string fullyQualifiedName) |
||||
{ |
||||
CreateField(fullyQualifiedName); |
||||
Field.Stub(f => f.IsPublic).Return(true); |
||||
} |
||||
|
||||
public void CreatePrivateField(string fullyQualifiedName) |
||||
{ |
||||
CreateField(fullyQualifiedName); |
||||
Field.Stub(f => f.IsPublic).Return(false); |
||||
Field.Stub(f => f.IsPrivate).Return(true); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// 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 MethodHelper |
||||
{ |
||||
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.FakeProjectContent); |
||||
Method.Stub(m => m.FullyQualifiedName).Return(fullyQualifiedName); |
||||
} |
||||
|
||||
public void CreatePublicMethod(string name) |
||||
{ |
||||
CreateMethod(name); |
||||
Method.Stub(m => m.IsPublic).Return(true); |
||||
} |
||||
|
||||
public void CreatePrivateMethod(string name) |
||||
{ |
||||
CreateMethod(name); |
||||
Method.Stub(m => m.IsPublic).Return(false); |
||||
Method.Stub(m => m.IsPrivate).Return(true); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue