14 changed files with 221 additions and 3 deletions
@ -0,0 +1,21 @@ |
|||||||
|
// 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.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.EnvDTE |
||||||
|
{ |
||||||
|
public class ProjectObject |
||||||
|
{ |
||||||
|
MSBuildBasedProject project; |
||||||
|
|
||||||
|
public ProjectObject(MSBuildBasedProject project) |
||||||
|
{ |
||||||
|
this.project = project; |
||||||
|
References = new References(project); |
||||||
|
} |
||||||
|
|
||||||
|
public References References { get; private set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
// 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.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.EnvDTE |
||||||
|
{ |
||||||
|
public class Properties |
||||||
|
{ |
||||||
|
MSBuildBasedProject project; |
||||||
|
|
||||||
|
public Properties(MSBuildBasedProject project) |
||||||
|
{ |
||||||
|
this.project = project; |
||||||
|
} |
||||||
|
|
||||||
|
public Property Item(string propertyName) |
||||||
|
{ |
||||||
|
return new Property(project, propertyName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
// 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.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.EnvDTE |
||||||
|
{ |
||||||
|
public class Property |
||||||
|
{ |
||||||
|
MSBuildBasedProject project; |
||||||
|
string name; |
||||||
|
|
||||||
|
public Property(MSBuildBasedProject project, string name) |
||||||
|
{ |
||||||
|
this.project = project; |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
public object Value { |
||||||
|
get { return project.GetEvaluatedProperty(name); } |
||||||
|
set { |
||||||
|
bool escapeValue = false; |
||||||
|
project.SetProperty(name, value as string, escapeValue); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
// 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.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.EnvDTE |
||||||
|
{ |
||||||
|
public class References |
||||||
|
{ |
||||||
|
MSBuildBasedProject project; |
||||||
|
IPackageManagementProjectService projectService; |
||||||
|
|
||||||
|
public References(MSBuildBasedProject project) |
||||||
|
: this(project, new PackageManagementProjectService()) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public References( |
||||||
|
MSBuildBasedProject project, |
||||||
|
IPackageManagementProjectService projectService) |
||||||
|
{ |
||||||
|
this.project = project; |
||||||
|
this.projectService = projectService; |
||||||
|
} |
||||||
|
|
||||||
|
public void Add(string path) |
||||||
|
{ |
||||||
|
var referenceItem = new ReferenceProjectItem(project, path); |
||||||
|
projectService.AddProjectItem(project, referenceItem); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
// 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 ICSharpCode.SharpDevelop.Project; |
||||||
|
using NUnit.Framework; |
||||||
|
using PackageManagement.Tests.Helpers; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests.EnvDTE |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ProjectTests |
||||||
|
{ |
||||||
|
Project project; |
||||||
|
TestableProject msbuildProject; |
||||||
|
|
||||||
|
void CreateProject() |
||||||
|
{ |
||||||
|
msbuildProject = ProjectHelper.CreateTestProject(); |
||||||
|
project = new Project(msbuildProject); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ObjectReferencesAdd_AddGacAssemblyReference_ReferenceAddedToMSBuildProject() |
||||||
|
{ |
||||||
|
CreateProject(); |
||||||
|
project.Object.References.Add("System.Data"); |
||||||
|
|
||||||
|
var reference = msbuildProject.Items[0] as ReferenceProjectItem; |
||||||
|
string referenceName = reference.Name; |
||||||
|
|
||||||
|
Assert.AreEqual("System.Data", referenceName); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PropertiesItemValue_GetPostBuildEvent_ReturnsProjectsPostBuildEvent() |
||||||
|
{ |
||||||
|
CreateProject(); |
||||||
|
msbuildProject.SetProperty("PostBuildEvent", "Test"); |
||||||
|
var postBuildEventProperty = project.Properties.Item("PostBuildEvent").Value; |
||||||
|
|
||||||
|
Assert.AreEqual("Test", postBuildEventProperty); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PropertiesItemValue_SetPostBuildEvent_UpdatesProjectsPostBuildEvent() |
||||||
|
{ |
||||||
|
CreateProject(); |
||||||
|
project.Properties.Item("PostBuildEvent").Value = "Test"; |
||||||
|
|
||||||
|
string postBuildEventProperty = msbuildProject.GetEvaluatedProperty("PostBuildEvent"); |
||||||
|
|
||||||
|
Assert.AreEqual("Test", postBuildEventProperty); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PropertiesItemValue_SetPostBuildEvent_DoesNotEscapeText() |
||||||
|
{ |
||||||
|
CreateProject(); |
||||||
|
project.Properties.Item("PostBuildEvent").Value = "$(SolutionDir)"; |
||||||
|
|
||||||
|
string postBuildEventProperty = msbuildProject.GetUnevalatedProperty("PostBuildEvent"); |
||||||
|
|
||||||
|
Assert.AreEqual("$(SolutionDir)", postBuildEventProperty); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue