1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
4
using Microsoft.Build.Construction;
7
using ICSharpCode.SharpDevelop;
8
using ICSharpCode.SharpDevelop.Dom;
9
using ICSharpCode.SharpDevelop.Internal.Templates;
10
using ICSharpCode.SharpDevelop.Project;
11
using ICSharpCode.WixBinding;
12
using NUnit.Framework;
13
using WixBinding.Tests.Utils;
15
namespace WixBinding.Tests.Project
18
/// Tests the initial properties set in a newly created WixProject.
21
public class CreateNewWixProjectObjectTestFixture
23
ProjectCreateInformation info;
27
public void SetUpFixture()
29
WixBindingTestsHelper.InitMSBuildEngine();
31
info = new ProjectCreateInformation();
32
info.Solution = new Solution(new MockProjectChangeWatcher());
33
info.ProjectName = "Test";
34
info.OutputProjectFileName = @"C:\Projects\Test\Test.wixproj";
35
info.RootNamespace = "Test";
37
project = new WixProject(info);
41
public void Language()
43
Assert.AreEqual(WixProjectBinding.LanguageName, project.Language);
49
Assert.AreEqual(info.ProjectName, project.Name);
53
public void OutputName()
55
Assert.AreEqual(info.ProjectName, project.GetEvaluatedProperty("OutputName"));
59
public void OutputType()
61
Assert.AreEqual(WixOutputType.Package.ToString(), project.GetEvaluatedProperty("OutputType"));
67
lock (project.SyncRoot) {
68
Assert.AreEqual(1, project.MSBuildProjectFile.Imports.Count());
69
Assert.AreEqual(WixProject.DefaultTargetsFile, project.MSBuildProjectFile.Imports.Single().Project);
74
public void WixToolPath()
76
Assert.AreEqual(@"$(SharpDevelopBinPath)\Tools\Wix", project.GetUnevalatedProperty("WixToolPath"));
80
public void WixToolPathCondition()
82
ProjectPropertyElement property = GetMSBuildProperty("WixToolPath");
83
Assert.AreEqual(" '$(WixToolPath)' == '' ", property.Condition);
87
public void ToolPathDoesNotExist()
89
Assert.IsNull(project.GetUnevalatedProperty("ToolPath"));
93
public void WixMSBuildExtensionsPathShouldNotExist()
95
Assert.IsNull(project.GetUnevalatedProperty("WixMSBuildExtensionsPath"));
99
public void WixTargetsPath()
101
Assert.AreEqual(@"$(WixToolPath)\wix.targets", project.GetUnevalatedProperty("WixTargetsPath"));
105
public void WixTargetsPathCondition()
107
ProjectPropertyElement property = GetMSBuildProperty("WixTargetsPath");
108
Assert.AreEqual(" '$(WixTargetsPath)' == '' ", property.Condition);
112
public void WixTasksPath()
114
Assert.AreEqual(@"$(WixToolPath)\WixTasks.dll", project.GetUnevalatedProperty("WixTasksPath"));
118
public void WixTasksPathCondition()
120
ProjectPropertyElement property = GetMSBuildProperty("WixTasksPath");
121
Assert.AreEqual(" '$(WixTasksPath)' == '' ", property.Condition);
125
public void DebugConfiguration()
127
Assert.AreEqual("Debug", project.GetEvaluatedProperty("Configuration"));
131
public void FileName()
133
Assert.AreEqual(info.OutputProjectFileName, project.FileName);
137
public void AssemblyName()
139
Assert.AreEqual("Test", project.AssemblyName);
143
public void UnknownProperty()
145
IWixPropertyValueProvider provider = (IWixPropertyValueProvider)project;
146
Assert.IsNull(provider.GetValue("UnknownMSBuildProperty"));
150
public void ProjectLanguageProperties()
152
Assert.AreEqual(LanguageProperties.None, project.LanguageProperties);
156
/// Gets the MSBuild build property with the specified name from the WixProject.
158
ProjectPropertyElement GetMSBuildProperty(string name)
160
foreach (ProjectPropertyGroupElement propertyGroup in project.MSBuildProjectFile.PropertyGroups) {
161
foreach (ProjectPropertyElement element in propertyGroup.Properties) {
162
if (element.Name == name) {