~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/Project/CreateNewWixProjectObjectTestFixture.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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)
 
3
 
 
4
using Microsoft.Build.Construction;
 
5
using System;
 
6
using System.Linq;
 
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;
 
14
 
 
15
namespace WixBinding.Tests.Project
 
16
{
 
17
        /// <summary>
 
18
        /// Tests the initial properties set in a newly created WixProject.
 
19
        /// </summary>
 
20
        [TestFixture]
 
21
        public class CreateNewWixProjectObjectTestFixture
 
22
        {
 
23
                ProjectCreateInformation info;
 
24
                WixProject project;
 
25
                
 
26
                [TestFixtureSetUp]
 
27
                public void SetUpFixture()
 
28
                {
 
29
                        WixBindingTestsHelper.InitMSBuildEngine();
 
30
                        
 
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";
 
36
 
 
37
                        project = new WixProject(info);
 
38
                }
 
39
                
 
40
                [Test]
 
41
                public void Language()
 
42
                {
 
43
                        Assert.AreEqual(WixProjectBinding.LanguageName, project.Language);
 
44
                }
 
45
                
 
46
                [Test]
 
47
                public void Name()
 
48
                {
 
49
                        Assert.AreEqual(info.ProjectName, project.Name);
 
50
                }
 
51
                
 
52
                [Test]
 
53
                public void OutputName()
 
54
                {
 
55
                        Assert.AreEqual(info.ProjectName, project.GetEvaluatedProperty("OutputName"));
 
56
                }
 
57
                
 
58
                [Test]
 
59
                public void OutputType()
 
60
                {
 
61
                        Assert.AreEqual(WixOutputType.Package.ToString(), project.GetEvaluatedProperty("OutputType"));
 
62
                }
 
63
                
 
64
                [Test]
 
65
                public void Imports()
 
66
                {
 
67
                        lock (project.SyncRoot) {
 
68
                                Assert.AreEqual(1, project.MSBuildProjectFile.Imports.Count());
 
69
                                Assert.AreEqual(WixProject.DefaultTargetsFile, project.MSBuildProjectFile.Imports.Single().Project);
 
70
                        }
 
71
                }
 
72
                
 
73
                [Test]
 
74
                public void WixToolPath()
 
75
                {
 
76
                        Assert.AreEqual(@"$(SharpDevelopBinPath)\Tools\Wix", project.GetUnevalatedProperty("WixToolPath"));
 
77
                }
 
78
                
 
79
                [Test]
 
80
                public void WixToolPathCondition()
 
81
                {
 
82
                        ProjectPropertyElement property = GetMSBuildProperty("WixToolPath");
 
83
                        Assert.AreEqual(" '$(WixToolPath)' == '' ", property.Condition);
 
84
                }
 
85
                
 
86
                [Test]
 
87
                public void ToolPathDoesNotExist()
 
88
                {
 
89
                        Assert.IsNull(project.GetUnevalatedProperty("ToolPath"));
 
90
                }
 
91
                
 
92
                [Test]
 
93
                public void WixMSBuildExtensionsPathShouldNotExist()
 
94
                {
 
95
                        Assert.IsNull(project.GetUnevalatedProperty("WixMSBuildExtensionsPath"));
 
96
                }
 
97
                
 
98
                [Test]
 
99
                public void WixTargetsPath()
 
100
                {
 
101
                        Assert.AreEqual(@"$(WixToolPath)\wix.targets", project.GetUnevalatedProperty("WixTargetsPath"));
 
102
                }
 
103
 
 
104
                [Test]
 
105
                public void WixTargetsPathCondition()
 
106
                {
 
107
                        ProjectPropertyElement property = GetMSBuildProperty("WixTargetsPath");
 
108
                        Assert.AreEqual(" '$(WixTargetsPath)' == '' ", property.Condition);
 
109
                }
 
110
 
 
111
                [Test]
 
112
                public void WixTasksPath()
 
113
                {
 
114
                        Assert.AreEqual(@"$(WixToolPath)\WixTasks.dll", project.GetUnevalatedProperty("WixTasksPath"));
 
115
                }
 
116
 
 
117
                [Test]
 
118
                public void WixTasksPathCondition()
 
119
                {
 
120
                        ProjectPropertyElement property = GetMSBuildProperty("WixTasksPath");
 
121
                        Assert.AreEqual(" '$(WixTasksPath)' == '' ", property.Condition);
 
122
                }
 
123
 
 
124
                [Test]
 
125
                public void DebugConfiguration()
 
126
                {
 
127
                        Assert.AreEqual("Debug", project.GetEvaluatedProperty("Configuration"));
 
128
                }
 
129
                
 
130
                [Test]
 
131
                public void FileName()
 
132
                {
 
133
                        Assert.AreEqual(info.OutputProjectFileName, project.FileName);
 
134
                }
 
135
                
 
136
                [Test]
 
137
                public void AssemblyName()
 
138
                {
 
139
                        Assert.AreEqual("Test", project.AssemblyName);
 
140
                }
 
141
                
 
142
                [Test]
 
143
                public void UnknownProperty()
 
144
                {
 
145
                        IWixPropertyValueProvider provider = (IWixPropertyValueProvider)project;
 
146
                        Assert.IsNull(provider.GetValue("UnknownMSBuildProperty"));
 
147
                }
 
148
                
 
149
                [Test]
 
150
                public void ProjectLanguageProperties()
 
151
                {
 
152
                        Assert.AreEqual(LanguageProperties.None, project.LanguageProperties);
 
153
                }
 
154
                
 
155
                /// <summary>
 
156
                /// Gets the MSBuild build property with the specified name from the WixProject.
 
157
                /// </summary>
 
158
                ProjectPropertyElement GetMSBuildProperty(string name)
 
159
                {
 
160
                        foreach (ProjectPropertyGroupElement propertyGroup in project.MSBuildProjectFile.PropertyGroups) {
 
161
                                foreach (ProjectPropertyElement element in propertyGroup.Properties) {
 
162
                                        if (element.Name == name) {
 
163
                                                return element;
 
164
                                        }
 
165
                                }
 
166
                        }
 
167
                        return null;
 
168
                }
 
169
        }
 
170
}