Browse Source

Ported WixBinding.Tests to MSBuild 4.0.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/dotnet4@4300 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
13a3c93e61
  1. 40
      src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs
  2. 51
      src/AddIns/BackendBindings/WixBinding/Test/Project/CreateWixProjectItemTests.cs
  3. 12
      src/AddIns/BackendBindings/WixBinding/Test/Project/WixBuilderCannotBuildNonWixProjectTestFixture.cs
  4. 2
      src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj
  5. 57
      src/Main/Base/Project/Src/Project/Items/ProjectItem.cs
  6. 4
      src/Main/Base/Project/Src/Project/MSBuildItemWrapper.cs

40
src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using Microsoft.Build.Construction;
using System;
using System.Linq;
using ICSharpCode.SharpDevelop;
@ -12,7 +13,6 @@ using ICSharpCode.SharpDevelop.Dom; @@ -12,7 +13,6 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.WixBinding;
using MSBuild = Microsoft.Build.BuildEngine;
using NUnit.Framework;
using WixBinding.Tests.Utils;
@ -68,17 +68,10 @@ namespace WixBinding.Tests.Project @@ -68,17 +68,10 @@ namespace WixBinding.Tests.Project
[Test]
public void Imports()
{
// this is machine-dependent, it's possible that additional imports are loaded
//Assert.AreEqual(2, project.MSBuildProject.Imports.Count);
Microsoft.Build.BuildEngine.Import[] imports = new Microsoft.Build.BuildEngine.Import[project.MSBuildProject.Imports.Count];
project.MSBuildProject.Imports.CopyTo(imports, 0);
string[] paths = new string[imports.Length];
for (int i = 0; i < imports.Length; i++) {
paths[i] = imports[i].ProjectPath;
lock (project.SyncRoot) {
Assert.AreEqual(1, project.MSBuildProjectFile.Imports.Count());
Assert.AreEqual(WixProject.DefaultTargetsFile, project.MSBuildProjectFile.Imports.Single().Project);
}
Assert.Contains(WixProject.DefaultTargetsFile, paths);
}
[Test]
@ -90,7 +83,7 @@ namespace WixBinding.Tests.Project @@ -90,7 +83,7 @@ namespace WixBinding.Tests.Project
[Test]
public void WixToolPathCondition()
{
MSBuild.BuildProperty property = GetMSBuildProperty("WixToolPath");
ProjectPropertyElement property = GetMSBuildProperty("WixToolPath");
Assert.AreEqual(" '$(WixToolPath)' == '' ", property.Condition);
}
@ -99,13 +92,13 @@ namespace WixBinding.Tests.Project @@ -99,13 +92,13 @@ namespace WixBinding.Tests.Project
{
Assert.IsNull(project.GetUnevalatedProperty("ToolPath"));
}
[Test]
public void WixMSBuildExtensionsPathShouldNotExist()
{
Assert.IsNull(project.GetUnevalatedProperty("WixMSBuildExtensionsPath"));
}
[Test]
public void WixTargetsPath()
{
@ -115,7 +108,7 @@ namespace WixBinding.Tests.Project @@ -115,7 +108,7 @@ namespace WixBinding.Tests.Project
[Test]
public void WixTargetsPathCondition()
{
MSBuild.BuildProperty property = GetMSBuildProperty("WixTargetsPath");
ProjectPropertyElement property = GetMSBuildProperty("WixTargetsPath");
Assert.AreEqual(" '$(WixTargetsPath)' == '' ", property.Condition);
}
@ -128,7 +121,7 @@ namespace WixBinding.Tests.Project @@ -128,7 +121,7 @@ namespace WixBinding.Tests.Project
[Test]
public void WixTasksPathCondition()
{
MSBuild.BuildProperty property = GetMSBuildProperty("WixTasksPath");
ProjectPropertyElement property = GetMSBuildProperty("WixTasksPath");
Assert.AreEqual(" '$(WixTasksPath)' == '' ", property.Condition);
}
@ -165,15 +158,12 @@ namespace WixBinding.Tests.Project @@ -165,15 +158,12 @@ namespace WixBinding.Tests.Project
/// <summary>
/// Gets the MSBuild build property with the specified name from the WixProject.
/// </summary>
MSBuild.BuildProperty GetMSBuildProperty(string name)
{
MSBuild.Project msbuildProject = project.MSBuildProject;
foreach (MSBuild.BuildPropertyGroup g in msbuildProject.PropertyGroups.Cast<MSBuild.BuildPropertyGroup>().ToList()) {
if (!g.IsImported) {
MSBuild.BuildProperty property = MSBuildInternals.GetProperty(g, name);
if (property != null) {
return property;
}
ProjectPropertyElement GetMSBuildProperty(string name)
{
foreach (ProjectPropertyGroupElement g in project.MSBuildProjectFile.PropertyGroups) {
foreach (ProjectPropertyElement element in g.Properties) {
if (element.Name == name)
return element;
}
}
return null;

51
src/AddIns/BackendBindings/WixBinding/Test/Project/CreateWixProjectItemTests.cs

@ -5,13 +5,13 @@ @@ -5,13 +5,13 @@
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.WixBinding;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using WixBinding.Tests.Utils;
using Microsoft.Build.BuildEngine;
namespace WixBinding.Tests.Project
{
@ -21,6 +21,53 @@ namespace WixBinding.Tests.Project @@ -21,6 +21,53 @@ namespace WixBinding.Tests.Project
[TestFixture]
public class CreateWixProjectItemTests
{
class BuildItem : IProjectItemBackendStore
{
public BuildItem(string type, string include)
{
this.ItemType = new ItemType(type);
this.UnevaluatedInclude = include;
this.EvaluatedInclude = include;
}
/// Gets the owning project.
public IProject Project { get { throw new NotImplementedException(); } }
public string UnevaluatedInclude { get; set; }
public string EvaluatedInclude { get; set; }
public ItemType ItemType { get; set; }
public string GetEvaluatedMetadata(string name)
{
throw new NotImplementedException();
}
public string GetMetadata(string name)
{
throw new NotImplementedException();
}
public bool HasMetadata(string name)
{
throw new NotImplementedException();
}
public void RemoveMetadata(string name)
{
throw new NotImplementedException();
}
public void SetEvaluatedMetadata(string name, string value)
{
throw new NotImplementedException();
}
public void SetMetadata(string name, string value)
{
throw new NotImplementedException();
}
public IEnumerable<string> MetadataNames {
get {
throw new NotImplementedException();
}
}
}
[Test]
public void CreateReferenceProjectItem()
{

12
src/AddIns/BackendBindings/WixBinding/Test/Project/WixBuilderCannotBuildNonWixProjectTestFixture.cs

@ -5,10 +5,11 @@ @@ -5,10 +5,11 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Internal.Templates;
using System;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.WixBinding;
using NUnit.Framework;
using System;
namespace WixBinding.Tests.Project
{
@ -25,9 +26,14 @@ namespace WixBinding.Tests.Project @@ -25,9 +26,14 @@ namespace WixBinding.Tests.Project
public void SetUpFixture()
{
wixNodeBuilder = new WixProjectNodeBuilder();
project = new MSBuildBasedProject(MSBuildInternals.CreateEngine());
project = new MSBuildBasedProject(
new ProjectCreateInformation {
OutputProjectFileName = @"C:\Projects\Test\test.csproj",
Solution = new Solution(),
ProjectName = "test"
}
);
project.IdGuid = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF";
project.FileName = @"C:\Projects\Test\test.csproj";
}
[Test]

2
src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
@ -44,7 +45,6 @@ @@ -44,7 +45,6 @@
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="Microsoft.Build.Framework" />
</ItemGroup>
<ItemGroup>

57
src/Main/Base/Project/Src/Project/Items/ProjectItem.cs

@ -344,16 +344,67 @@ namespace ICSharpCode.SharpDevelop.Project @@ -344,16 +344,67 @@ namespace ICSharpCode.SharpDevelop.Project
// use CreateProjectItem to ensure the clone has the same class
// (derived from ProjectItem)
ProjectItem copy = targetProject.CreateProjectItem(CloneBuildItem());
ProjectItem copy = targetProject.CreateProjectItem(new CloneBuildItem(this));
// remove reference to cloned item, leaving an unbound project item
copy.BuildItem = null;
return copy;
}
IProjectItemBackendStore CloneBuildItem()
class CloneBuildItem : IProjectItemBackendStore
{
throw new NotImplementedException();
ProjectItem parent;
public CloneBuildItem(ProjectItem parent)
{
this.parent = parent;
}
/// Gets the owning project.
public IProject Project {
get { throw new NotSupportedException(); }
}
public string UnevaluatedInclude {
get { return parent.Include; }
set { throw new NotSupportedException(); }
}
public string EvaluatedInclude {
get { return parent.Include; }
set { throw new NotSupportedException(); }
}
public ItemType ItemType {
get { return parent.ItemType; }
set { throw new NotSupportedException(); }
}
public string GetEvaluatedMetadata(string name)
{
return parent.GetEvaluatedMetadata(name);
}
public string GetMetadata(string name)
{
return parent.GetMetadata(name);
}
public bool HasMetadata(string name)
{
return parent.HasMetadata(name);
}
public void RemoveMetadata(string name)
{
parent.RemoveMetadata(name);
}
public void SetEvaluatedMetadata(string name, string value)
{
parent.SetEvaluatedMetadata(name, value);
}
public void SetMetadata(string name, string value)
{
parent.SetMetadata(name, value);
}
public IEnumerable<string> MetadataNames {
get { return parent.MetadataNames; }
}
}
object ICloneable.Clone()

4
src/Main/Base/Project/Src/Project/MSBuildItemWrapper.cs

@ -37,8 +37,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -37,8 +37,8 @@ namespace ICSharpCode.SharpDevelop.Project
set { item.UnevaluatedInclude = value; }
}
public string EvaluatedInclude {
get { return item.UnevaluatedInclude; }
set { item.UnevaluatedInclude = value; }
get { return item.EvaluatedInclude; }
set { item.UnevaluatedInclude = MSBuildInternals.Escape(value); }
}
public ItemType ItemType {

Loading…
Cancel
Save