Browse Source

Implement EnvDTE.CodeProperty.Attributes.

pull/28/head
Matt Ward 14 years ago
parent
commit
5f7c2da16e
  1. 16
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty.cs
  2. 4
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty2.cs
  3. 2
      src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
  4. 43
      src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeProperty2Tests.cs
  5. 29
      src/AddIns/Misc/PackageManagement/Test/Src/Helpers/PropertyHelper.cs

16
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty.cs

@ -2,15 +2,24 @@ @@ -2,15 +2,24 @@
// 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 CodeProperty : CodeElement
{
IProperty property;
CodeElements attributes;
public CodeProperty()
{
}
public CodeProperty(IProperty property)
{
this.property = property;
}
public virtual vsCMAccess Access { get; set; }
public virtual CodeClass Parent {
@ -18,7 +27,12 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -18,7 +27,12 @@ namespace ICSharpCode.PackageManagement.EnvDTE
}
public virtual CodeElements Attributes {
get { throw new NotImplementedException(); }
get {
if (attributes == null) {
attributes = new CodeAttributes(property);
}
return attributes;
}
}
public virtual CodeTypeRef Type {

4
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeProperty2.cs

@ -2,12 +2,14 @@ @@ -2,12 +2,14 @@
// 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 CodeProperty2 : CodeProperty
{
public CodeProperty2()
public CodeProperty2(IProperty property)
: base(property)
{
}

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

@ -78,6 +78,7 @@ @@ -78,6 +78,7 @@
<Compile Include="Src\EnvDTE\CodeElementsInNamespaceTests.cs" />
<Compile Include="Src\EnvDTE\CodeModelTests.cs" />
<Compile Include="Src\EnvDTE\CodeNamespaceTests.cs" />
<Compile Include="Src\EnvDTE\CodeProperty2Tests.cs" />
<Compile Include="Src\EnvDTE\CodeTypeTests.cs" />
<Compile Include="Src\EnvDTE\NamespaceNameTests.cs" />
<Compile Include="Src\EnvDTE\SolutionTests.cs" />
@ -89,6 +90,7 @@ @@ -89,6 +90,7 @@
<Compile Include="Src\Helpers\FakeUpdatePackageActionsFactory.cs" />
<Compile Include="Src\Helpers\ProjectContentHelper.cs" />
<Compile Include="Src\Helpers\PropertiesHelper.cs" />
<Compile Include="Src\Helpers\PropertyHelper.cs" />
<Compile Include="Src\Helpers\SelectedProjectCollectionAssert.cs" />
<Compile Include="Src\Helpers\TestableInstalledPackageViewModel.cs" />
<Compile Include="Src\Helpers\TestablePackageFromRepository.cs" />

43
src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/CodeProperty2Tests.cs

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
// 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 CodeProperty2Tests
{
CodeProperty2 property;
PropertyHelper helper;
[SetUp]
public void Init()
{
helper = new PropertyHelper();
}
void CreateCodeProperty2()
{
property = new CodeProperty2(helper.Property);
}
[Test]
public void Attributes_PropertyHasOneAttribute_ReturnsOneAttribute()
{
helper.CreateProperty("MyProperty");
helper.AddAttribute("Tests.TestAttribute", "TestAttribute");
CreateCodeProperty2();
CodeElements attributes = property.Attributes;
CodeAttribute2 attribute = attributes.Item(1) as CodeAttribute2;
Assert.AreEqual(1, attributes.Count);
Assert.AreEqual("Tests.TestAttribute", attribute.FullName);
}
}
}

29
src/AddIns/Misc/PackageManagement/Test/Src/Helpers/PropertyHelper.cs

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
// 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 PropertyHelper
{
public IProperty Property;
public List<IAttribute> Attributes = new List<IAttribute>();
public void CreateProperty(string name)
{
Property = MockRepository.GenerateMock<IProperty, IEntity>();
Property.Stub(p => p.Attributes).Return(Attributes);
}
public void AddAttribute(string fullName, string shortName)
{
var attributeHelper = new AttributeHelper();
attributeHelper.CreateAttribute(fullName, shortName);
Attributes.Add(attributeHelper.Attribute);
}
}
}
Loading…
Cancel
Save