diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/WixToolsetTest.WixCop/ConverterFixture.cs (renamed from src/test/wixcop/ConverterFixture.cs) | 196 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/TestData/Preprocessor/ConvertedPreprocessor.wxs (renamed from src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs) | 0 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/TestData/Preprocessor/Preprocessor.wxs (renamed from src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs) | 0 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/TestData/Preprocessor/wixcop.settings.xml (renamed from src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml) | 0 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/TestData/SingleFile/ConvertedSingleFile.wxs (renamed from src/test/wixcop/TestData/SingleFile/ConvertedSingleFile.wxs) | 0 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/TestData/SingleFile/SingleFile.wxs (renamed from src/test/wixcop/TestData/SingleFile/SingleFile.wxs) | 0 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/WixCopFixture.cs (renamed from src/test/wixcop/WixCopFixture.cs) | 96 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/WixCopRunner.cs | 67 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/WixCopRunnerResult.cs | 22 | ||||
-rw-r--r-- | src/test/WixToolsetTest.WixCop/WixToolsetTest.WixCop.csproj (renamed from src/test/wixcop/WixCopTests.csproj) | 1 |
10 files changed, 226 insertions, 156 deletions
diff --git a/src/test/wixcop/ConverterFixture.cs b/src/test/WixToolsetTest.WixCop/ConverterFixture.cs index 45ccc33e..86931d5a 100644 --- a/src/test/wixcop/ConverterFixture.cs +++ b/src/test/WixToolsetTest.WixCop/ConverterFixture.cs | |||
@@ -1,16 +1,15 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
2 | 2 | ||
3 | namespace WixTest.WixUnitTest | 3 | namespace WixToolsetTest.WixCop |
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.IO; | 6 | using System.IO; |
7 | using System.Text; | 7 | using System.Text; |
8 | using System.Xml.Linq; | 8 | using System.Xml.Linq; |
9 | using WixCop; | ||
10 | using WixToolset; | ||
11 | using WixToolset.Data; | 9 | using WixToolset.Data; |
12 | using WixToolset.Extensibility; | 10 | using WixToolset.Extensibility; |
13 | using WixToolset.Extensibility.Services; | 11 | using WixToolset.Extensibility.Services; |
12 | using WixToolset.Tools.WixCop; | ||
14 | using Xunit; | 13 | using Xunit; |
15 | 14 | ||
16 | public class ConverterFixture | 15 | public class ConverterFixture |
@@ -20,25 +19,25 @@ namespace WixTest.WixUnitTest | |||
20 | [Fact] | 19 | [Fact] |
21 | public void EnsuresDeclaration() | 20 | public void EnsuresDeclaration() |
22 | { | 21 | { |
23 | string parse = String.Join(Environment.NewLine, | 22 | var parse = String.Join(Environment.NewLine, |
24 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | 23 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
25 | " <Fragment />", | 24 | " <Fragment />", |
26 | "</Wix>"); | 25 | "</Wix>"); |
27 | 26 | ||
28 | string expected = String.Join(Environment.NewLine, | 27 | var expected = String.Join(Environment.NewLine, |
29 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 28 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
30 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 29 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
31 | " <Fragment />", | 30 | " <Fragment />", |
32 | "</Wix>"); | 31 | "</Wix>"); |
33 | 32 | ||
34 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 33 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
35 | 34 | ||
36 | var messaging = new DummyMessaging(); | 35 | var messaging = new DummyMessaging(); |
37 | Converter converter = new Converter(messaging, 2, null, null); | 36 | var converter = new Converter(messaging, 2, null, null); |
38 | 37 | ||
39 | int errors = converter.ConvertDocument(document); | 38 | var errors = converter.ConvertDocument(document); |
40 | 39 | ||
41 | string actual = UnformattedDocumentString(document); | 40 | var actual = UnformattedDocumentString(document); |
42 | 41 | ||
43 | Assert.Equal(1, errors); | 42 | Assert.Equal(1, errors); |
44 | Assert.Equal(expected, actual); | 43 | Assert.Equal(expected, actual); |
@@ -47,18 +46,18 @@ namespace WixTest.WixUnitTest | |||
47 | [Fact] | 46 | [Fact] |
48 | public void EnsuresUtf8Declaration() | 47 | public void EnsuresUtf8Declaration() |
49 | { | 48 | { |
50 | string parse = String.Join(Environment.NewLine, | 49 | var parse = String.Join(Environment.NewLine, |
51 | "<?xml version='1.0'?>", | 50 | "<?xml version='1.0'?>", |
52 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | 51 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
53 | " <Fragment />", | 52 | " <Fragment />", |
54 | "</Wix>"); | 53 | "</Wix>"); |
55 | 54 | ||
56 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 55 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
57 | 56 | ||
58 | var messaging = new DummyMessaging(); | 57 | var messaging = new DummyMessaging(); |
59 | Converter converter = new Converter(messaging, 4, null, null); | 58 | var converter = new Converter(messaging, 4, null, null); |
60 | 59 | ||
61 | int errors = converter.ConvertDocument(document); | 60 | var errors = converter.ConvertDocument(document); |
62 | 61 | ||
63 | Assert.Equal(1, errors); | 62 | Assert.Equal(1, errors); |
64 | Assert.Equal("1.0", document.Declaration.Version); | 63 | Assert.Equal("1.0", document.Declaration.Version); |
@@ -68,7 +67,7 @@ namespace WixTest.WixUnitTest | |||
68 | [Fact] | 67 | [Fact] |
69 | public void CanFixWhitespace() | 68 | public void CanFixWhitespace() |
70 | { | 69 | { |
71 | string parse = String.Join(Environment.NewLine, | 70 | var parse = String.Join(Environment.NewLine, |
72 | "<?xml version='1.0' encoding='utf-8'?>", | 71 | "<?xml version='1.0' encoding='utf-8'?>", |
73 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | 72 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
74 | " <Fragment>", | 73 | " <Fragment>", |
@@ -78,7 +77,7 @@ namespace WixTest.WixUnitTest | |||
78 | " </Fragment>", | 77 | " </Fragment>", |
79 | "</Wix>"); | 78 | "</Wix>"); |
80 | 79 | ||
81 | string expected = String.Join(Environment.NewLine, | 80 | var expected = String.Join(Environment.NewLine, |
82 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 81 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
83 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 82 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
84 | " <Fragment>", | 83 | " <Fragment>", |
@@ -86,14 +85,14 @@ namespace WixTest.WixUnitTest | |||
86 | " </Fragment>", | 85 | " </Fragment>", |
87 | "</Wix>"); | 86 | "</Wix>"); |
88 | 87 | ||
89 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 88 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
90 | 89 | ||
91 | var messaging = new DummyMessaging(); | 90 | var messaging = new DummyMessaging(); |
92 | Converter converter = new Converter(messaging, 4, null, null); | 91 | var converter = new Converter(messaging, 4, null, null); |
93 | 92 | ||
94 | int errors = converter.ConvertDocument(document); | 93 | var errors = converter.ConvertDocument(document); |
95 | 94 | ||
96 | string actual = UnformattedDocumentString(document); | 95 | var actual = UnformattedDocumentString(document); |
97 | 96 | ||
98 | Assert.Equal(4, errors); | 97 | Assert.Equal(4, errors); |
99 | Assert.Equal(expected, actual); | 98 | Assert.Equal(expected, actual); |
@@ -102,7 +101,7 @@ namespace WixTest.WixUnitTest | |||
102 | [Fact] | 101 | [Fact] |
103 | public void CanFixCdataWhitespace() | 102 | public void CanFixCdataWhitespace() |
104 | { | 103 | { |
105 | string parse = String.Join(Environment.NewLine, | 104 | var parse = String.Join(Environment.NewLine, |
106 | "<?xml version='1.0' encoding='utf-8'?>", | 105 | "<?xml version='1.0' encoding='utf-8'?>", |
107 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | 106 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
108 | " <Fragment>", | 107 | " <Fragment>", |
@@ -112,7 +111,7 @@ namespace WixTest.WixUnitTest | |||
112 | " </Fragment>", | 111 | " </Fragment>", |
113 | "</Wix>"); | 112 | "</Wix>"); |
114 | 113 | ||
115 | string expected = String.Join(Environment.NewLine, | 114 | var expected = String.Join(Environment.NewLine, |
116 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 115 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
117 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 116 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
118 | " <Fragment>", | 117 | " <Fragment>", |
@@ -120,42 +119,78 @@ namespace WixTest.WixUnitTest | |||
120 | " </Fragment>", | 119 | " </Fragment>", |
121 | "</Wix>"); | 120 | "</Wix>"); |
122 | 121 | ||
123 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 122 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
124 | 123 | ||
125 | var messaging = new DummyMessaging(); | 124 | var messaging = new DummyMessaging(); |
126 | Converter converter = new Converter(messaging, 2, null, null); | 125 | var converter = new Converter(messaging, 2, null, null); |
127 | 126 | ||
128 | int errors = converter.ConvertDocument(document); | 127 | var errors = converter.ConvertDocument(document); |
129 | 128 | ||
130 | string actual = UnformattedDocumentString(document); | 129 | var actual = UnformattedDocumentString(document); |
131 | 130 | ||
131 | Assert.Equal(expected, actual); | ||
132 | Assert.Equal(2, errors); | 132 | Assert.Equal(2, errors); |
133 | } | ||
134 | |||
135 | [Fact] | ||
136 | public void CanFixCdataWithWhitespace() | ||
137 | { | ||
138 | var parse = String.Join(Environment.NewLine, | ||
139 | "<?xml version='1.0' encoding='utf-8'?>", | ||
140 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
141 | " <Fragment>", | ||
142 | " <Property Id='Prop'>", | ||
143 | " <![CDATA[", | ||
144 | " 1<2", | ||
145 | " ]]>", | ||
146 | " </Property>", | ||
147 | " </Fragment>", | ||
148 | "</Wix>"); | ||
149 | |||
150 | var expected = String.Join(Environment.NewLine, | ||
151 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
152 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
153 | " <Fragment>", | ||
154 | " <Property Id=\"Prop\"><![CDATA[1<2]]></Property>", | ||
155 | " </Fragment>", | ||
156 | "</Wix>"); | ||
157 | |||
158 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
159 | |||
160 | var messaging = new DummyMessaging(); | ||
161 | var converter = new Converter(messaging, 2, null, null); | ||
162 | |||
163 | var errors = converter.ConvertDocument(document); | ||
164 | |||
165 | var actual = UnformattedDocumentString(document); | ||
166 | |||
133 | Assert.Equal(expected, actual); | 167 | Assert.Equal(expected, actual); |
168 | Assert.Equal(2, errors); | ||
134 | } | 169 | } |
135 | 170 | ||
136 | [Fact] | 171 | [Fact] |
137 | public void CanConvertMainNamespace() | 172 | public void CanConvertMainNamespace() |
138 | { | 173 | { |
139 | string parse = String.Join(Environment.NewLine, | 174 | var parse = String.Join(Environment.NewLine, |
140 | "<?xml version='1.0' encoding='utf-8'?>", | 175 | "<?xml version='1.0' encoding='utf-8'?>", |
141 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | 176 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", |
142 | " <Fragment />", | 177 | " <Fragment />", |
143 | "</Wix>"); | 178 | "</Wix>"); |
144 | 179 | ||
145 | string expected = String.Join(Environment.NewLine, | 180 | var expected = String.Join(Environment.NewLine, |
146 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 181 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
147 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 182 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
148 | " <Fragment />", | 183 | " <Fragment />", |
149 | "</Wix>"); | 184 | "</Wix>"); |
150 | 185 | ||
151 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 186 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
152 | 187 | ||
153 | var messaging = new DummyMessaging(); | 188 | var messaging = new DummyMessaging(); |
154 | Converter converter = new Converter(messaging, 2, null, null); | 189 | var converter = new Converter(messaging, 2, null, null); |
155 | 190 | ||
156 | int errors = converter.ConvertDocument(document); | 191 | var errors = converter.ConvertDocument(document); |
157 | 192 | ||
158 | string actual = UnformattedDocumentString(document); | 193 | var actual = UnformattedDocumentString(document); |
159 | 194 | ||
160 | Assert.Equal(1, errors); | 195 | Assert.Equal(1, errors); |
161 | //Assert.Equal(Wix4Namespace, document.Root.GetDefaultNamespace()); | 196 | //Assert.Equal(Wix4Namespace, document.Root.GetDefaultNamespace()); |
@@ -165,26 +200,26 @@ namespace WixTest.WixUnitTest | |||
165 | [Fact] | 200 | [Fact] |
166 | public void CanConvertNamedMainNamespace() | 201 | public void CanConvertNamedMainNamespace() |
167 | { | 202 | { |
168 | string parse = String.Join(Environment.NewLine, | 203 | var parse = String.Join(Environment.NewLine, |
169 | "<?xml version='1.0' encoding='utf-8'?>", | 204 | "<?xml version='1.0' encoding='utf-8'?>", |
170 | "<w:Wix xmlns:w='http://schemas.microsoft.com/wix/2006/wi'>", | 205 | "<w:Wix xmlns:w='http://schemas.microsoft.com/wix/2006/wi'>", |
171 | " <w:Fragment />", | 206 | " <w:Fragment />", |
172 | "</w:Wix>"); | 207 | "</w:Wix>"); |
173 | 208 | ||
174 | string expected = String.Join(Environment.NewLine, | 209 | var expected = String.Join(Environment.NewLine, |
175 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 210 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
176 | "<w:Wix xmlns:w=\"http://wixtoolset.org/schemas/v4/wxs\">", | 211 | "<w:Wix xmlns:w=\"http://wixtoolset.org/schemas/v4/wxs\">", |
177 | " <w:Fragment />", | 212 | " <w:Fragment />", |
178 | "</w:Wix>"); | 213 | "</w:Wix>"); |
179 | 214 | ||
180 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 215 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
181 | 216 | ||
182 | var messaging = new DummyMessaging(); | 217 | var messaging = new DummyMessaging(); |
183 | Converter converter = new Converter(messaging, 2, null, null); | 218 | var converter = new Converter(messaging, 2, null, null); |
184 | 219 | ||
185 | int errors = converter.ConvertDocument(document); | 220 | var errors = converter.ConvertDocument(document); |
186 | 221 | ||
187 | string actual = UnformattedDocumentString(document); | 222 | var actual = UnformattedDocumentString(document); |
188 | 223 | ||
189 | Assert.Equal(1, errors); | 224 | Assert.Equal(1, errors); |
190 | Assert.Equal(expected, actual); | 225 | Assert.Equal(expected, actual); |
@@ -194,7 +229,7 @@ namespace WixTest.WixUnitTest | |||
194 | [Fact] | 229 | [Fact] |
195 | public void CanConvertNonWixDefaultNamespace() | 230 | public void CanConvertNonWixDefaultNamespace() |
196 | { | 231 | { |
197 | string parse = String.Join(Environment.NewLine, | 232 | var parse = String.Join(Environment.NewLine, |
198 | "<?xml version='1.0' encoding='utf-8'?>", | 233 | "<?xml version='1.0' encoding='utf-8'?>", |
199 | "<w:Wix xmlns:w='http://schemas.microsoft.com/wix/2006/wi' xmlns='http://schemas.microsoft.com/wix/UtilExtension'>", | 234 | "<w:Wix xmlns:w='http://schemas.microsoft.com/wix/2006/wi' xmlns='http://schemas.microsoft.com/wix/UtilExtension'>", |
200 | " <w:Fragment>", | 235 | " <w:Fragment>", |
@@ -202,7 +237,7 @@ namespace WixTest.WixUnitTest | |||
202 | " </w:Fragment>", | 237 | " </w:Fragment>", |
203 | "</w:Wix>"); | 238 | "</w:Wix>"); |
204 | 239 | ||
205 | string expected = String.Join(Environment.NewLine, | 240 | var expected = String.Join(Environment.NewLine, |
206 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 241 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
207 | "<w:Wix xmlns:w=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | 242 | "<w:Wix xmlns:w=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns=\"http://wixtoolset.org/schemas/v4/wxs/util\">", |
208 | " <w:Fragment>", | 243 | " <w:Fragment>", |
@@ -210,17 +245,17 @@ namespace WixTest.WixUnitTest | |||
210 | " </w:Fragment>", | 245 | " </w:Fragment>", |
211 | "</w:Wix>"); | 246 | "</w:Wix>"); |
212 | 247 | ||
213 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 248 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
214 | 249 | ||
215 | var messaging = new DummyMessaging(); | 250 | var messaging = new DummyMessaging(); |
216 | Converter converter = new Converter(messaging, 2, null, null); | 251 | var converter = new Converter(messaging, 2, null, null); |
217 | 252 | ||
218 | int errors = converter.ConvertDocument(document); | 253 | var errors = converter.ConvertDocument(document); |
219 | 254 | ||
220 | string actual = UnformattedDocumentString(document); | 255 | var actual = UnformattedDocumentString(document); |
221 | 256 | ||
222 | Assert.Equal(2, errors); | ||
223 | Assert.Equal(expected, actual); | 257 | Assert.Equal(expected, actual); |
258 | Assert.Equal(2, errors); | ||
224 | Assert.Equal(Wix4Namespace, document.Root.GetNamespaceOfPrefix("w")); | 259 | Assert.Equal(Wix4Namespace, document.Root.GetNamespaceOfPrefix("w")); |
225 | Assert.Equal("http://wixtoolset.org/schemas/v4/wxs/util", document.Root.GetDefaultNamespace()); | 260 | Assert.Equal("http://wixtoolset.org/schemas/v4/wxs/util", document.Root.GetDefaultNamespace()); |
226 | } | 261 | } |
@@ -228,26 +263,26 @@ namespace WixTest.WixUnitTest | |||
228 | [Fact] | 263 | [Fact] |
229 | public void CanConvertExtensionNamespace() | 264 | public void CanConvertExtensionNamespace() |
230 | { | 265 | { |
231 | string parse = String.Join(Environment.NewLine, | 266 | var parse = String.Join(Environment.NewLine, |
232 | "<?xml version='1.0' encoding='utf-8'?>", | 267 | "<?xml version='1.0' encoding='utf-8'?>", |
233 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", | 268 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", |
234 | " <Fragment />", | 269 | " <Fragment />", |
235 | "</Wix>"); | 270 | "</Wix>"); |
236 | 271 | ||
237 | string expected = String.Join(Environment.NewLine, | 272 | var expected = String.Join(Environment.NewLine, |
238 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 273 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
239 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | 274 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", |
240 | " <Fragment />", | 275 | " <Fragment />", |
241 | "</Wix>"); | 276 | "</Wix>"); |
242 | 277 | ||
243 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 278 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
244 | 279 | ||
245 | var messaging = new DummyMessaging(); | 280 | var messaging = new DummyMessaging(); |
246 | Converter converter = new Converter(messaging, 2, null, null); | 281 | var converter = new Converter(messaging, 2, null, null); |
247 | 282 | ||
248 | int errors = converter.ConvertDocument(document); | 283 | var errors = converter.ConvertDocument(document); |
249 | 284 | ||
250 | string actual = UnformattedDocumentString(document); | 285 | var actual = UnformattedDocumentString(document); |
251 | 286 | ||
252 | Assert.Equal(2, errors); | 287 | Assert.Equal(2, errors); |
253 | Assert.Equal(expected, actual); | 288 | Assert.Equal(expected, actual); |
@@ -257,26 +292,26 @@ namespace WixTest.WixUnitTest | |||
257 | [Fact] | 292 | [Fact] |
258 | public void CanConvertMissingNamespace() | 293 | public void CanConvertMissingNamespace() |
259 | { | 294 | { |
260 | string parse = String.Join(Environment.NewLine, | 295 | var parse = String.Join(Environment.NewLine, |
261 | "<?xml version='1.0' encoding='utf-8'?>", | 296 | "<?xml version='1.0' encoding='utf-8'?>", |
262 | "<Wix>", | 297 | "<Wix>", |
263 | " <Fragment />", | 298 | " <Fragment />", |
264 | "</Wix>"); | 299 | "</Wix>"); |
265 | 300 | ||
266 | string expected = String.Join(Environment.NewLine, | 301 | var expected = String.Join(Environment.NewLine, |
267 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 302 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
268 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 303 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
269 | " <Fragment />", | 304 | " <Fragment />", |
270 | "</Wix>"); | 305 | "</Wix>"); |
271 | 306 | ||
272 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 307 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
273 | 308 | ||
274 | var messaging = new DummyMessaging(); | 309 | var messaging = new DummyMessaging(); |
275 | Converter converter = new Converter(messaging, 2, null, null); | 310 | var converter = new Converter(messaging, 2, null, null); |
276 | 311 | ||
277 | int errors = converter.ConvertDocument(document); | 312 | var errors = converter.ConvertDocument(document); |
278 | 313 | ||
279 | string actual = UnformattedDocumentString(document); | 314 | var actual = UnformattedDocumentString(document); |
280 | 315 | ||
281 | Assert.Equal(1, errors); | 316 | Assert.Equal(1, errors); |
282 | Assert.Equal(expected, actual); | 317 | Assert.Equal(expected, actual); |
@@ -286,26 +321,26 @@ namespace WixTest.WixUnitTest | |||
286 | [Fact] | 321 | [Fact] |
287 | public void CanConvertAnonymousFile() | 322 | public void CanConvertAnonymousFile() |
288 | { | 323 | { |
289 | string parse = String.Join(Environment.NewLine, | 324 | var parse = String.Join(Environment.NewLine, |
290 | "<?xml version='1.0' encoding='utf-8'?>", | 325 | "<?xml version='1.0' encoding='utf-8'?>", |
291 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | 326 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
292 | " <File Source='path\\to\\foo.txt' />", | 327 | " <File Source='path\\to\\foo.txt' />", |
293 | "</Wix>"); | 328 | "</Wix>"); |
294 | 329 | ||
295 | string expected = String.Join(Environment.NewLine, | 330 | var expected = String.Join(Environment.NewLine, |
296 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 331 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
297 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 332 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
298 | " <File Id=\"foo.txt\" Source=\"path\\to\\foo.txt\" />", | 333 | " <File Id=\"foo.txt\" Source=\"path\\to\\foo.txt\" />", |
299 | "</Wix>"); | 334 | "</Wix>"); |
300 | 335 | ||
301 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 336 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
302 | 337 | ||
303 | var messaging = new DummyMessaging(); | 338 | var messaging = new DummyMessaging(); |
304 | Converter converter = new Converter(messaging, 2, null, null); | 339 | var converter = new Converter(messaging, 2, null, null); |
305 | 340 | ||
306 | int errors = converter.ConvertDocument(document); | 341 | var errors = converter.ConvertDocument(document); |
307 | 342 | ||
308 | string actual = UnformattedDocumentString(document); | 343 | var actual = UnformattedDocumentString(document); |
309 | 344 | ||
310 | Assert.Equal(1, errors); | 345 | Assert.Equal(1, errors); |
311 | Assert.Equal(expected, actual); | 346 | Assert.Equal(expected, actual); |
@@ -314,26 +349,26 @@ namespace WixTest.WixUnitTest | |||
314 | [Fact] | 349 | [Fact] |
315 | public void CanConvertSuppressSignatureValidationNo() | 350 | public void CanConvertSuppressSignatureValidationNo() |
316 | { | 351 | { |
317 | string parse = String.Join(Environment.NewLine, | 352 | var parse = String.Join(Environment.NewLine, |
318 | "<?xml version='1.0' encoding='utf-8'?>", | 353 | "<?xml version='1.0' encoding='utf-8'?>", |
319 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | 354 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
320 | " <MsiPackage SuppressSignatureValidation='no' />", | 355 | " <MsiPackage SuppressSignatureValidation='no' />", |
321 | "</Wix>"); | 356 | "</Wix>"); |
322 | 357 | ||
323 | string expected = String.Join(Environment.NewLine, | 358 | var expected = String.Join(Environment.NewLine, |
324 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 359 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
325 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 360 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
326 | " <MsiPackage EnableSignatureValidation=\"yes\" />", | 361 | " <MsiPackage EnableSignatureValidation=\"yes\" />", |
327 | "</Wix>"); | 362 | "</Wix>"); |
328 | 363 | ||
329 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 364 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
330 | 365 | ||
331 | var messaging = new DummyMessaging(); | 366 | var messaging = new DummyMessaging(); |
332 | Converter converter = new Converter(messaging, 2, null, null); | 367 | var converter = new Converter(messaging, 2, null, null); |
333 | 368 | ||
334 | int errors = converter.ConvertDocument(document); | 369 | var errors = converter.ConvertDocument(document); |
335 | 370 | ||
336 | string actual = UnformattedDocumentString(document); | 371 | var actual = UnformattedDocumentString(document); |
337 | 372 | ||
338 | Assert.Equal(1, errors); | 373 | Assert.Equal(1, errors); |
339 | Assert.Equal(expected, actual); | 374 | Assert.Equal(expected, actual); |
@@ -342,26 +377,26 @@ namespace WixTest.WixUnitTest | |||
342 | [Fact] | 377 | [Fact] |
343 | public void CanConvertSuppressSignatureValidationYes() | 378 | public void CanConvertSuppressSignatureValidationYes() |
344 | { | 379 | { |
345 | string parse = String.Join(Environment.NewLine, | 380 | var parse = String.Join(Environment.NewLine, |
346 | "<?xml version='1.0' encoding='utf-8'?>", | 381 | "<?xml version='1.0' encoding='utf-8'?>", |
347 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | 382 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
348 | " <Payload SuppressSignatureValidation='yes' />", | 383 | " <Payload SuppressSignatureValidation='yes' />", |
349 | "</Wix>"); | 384 | "</Wix>"); |
350 | 385 | ||
351 | string expected = String.Join(Environment.NewLine, | 386 | var expected = String.Join(Environment.NewLine, |
352 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | 387 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", |
353 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | 388 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
354 | " <Payload />", | 389 | " <Payload />", |
355 | "</Wix>"); | 390 | "</Wix>"); |
356 | 391 | ||
357 | XDocument document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | 392 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
358 | 393 | ||
359 | var messaging = new DummyMessaging(); | 394 | var messaging = new DummyMessaging(); |
360 | Converter converter = new Converter(messaging, 2, null, null); | 395 | var converter = new Converter(messaging, 2, null, null); |
361 | 396 | ||
362 | int errors = converter.ConvertDocument(document); | 397 | var errors = converter.ConvertDocument(document); |
363 | 398 | ||
364 | string actual = UnformattedDocumentString(document); | 399 | var actual = UnformattedDocumentString(document); |
365 | 400 | ||
366 | Assert.Equal(1, errors); | 401 | Assert.Equal(1, errors); |
367 | Assert.Equal(expected, actual); | 402 | Assert.Equal(expected, actual); |
@@ -369,11 +404,11 @@ namespace WixTest.WixUnitTest | |||
369 | 404 | ||
370 | private static string UnformattedDocumentString(XDocument document) | 405 | private static string UnformattedDocumentString(XDocument document) |
371 | { | 406 | { |
372 | StringBuilder sb = new StringBuilder(); | 407 | var sb = new StringBuilder(); |
373 | 408 | ||
374 | using (StringWriter writer = new StringWriter(sb)) | 409 | using (var writer = new StringWriter(sb)) |
375 | { | 410 | { |
376 | document.Save(writer, SaveOptions.DisableFormatting | SaveOptions.OmitDuplicateNamespaces); | 411 | document.Save(writer, SaveOptions.DisableFormatting); |
377 | } | 412 | } |
378 | 413 | ||
379 | return sb.ToString(); | 414 | return sb.ToString(); |
@@ -386,17 +421,16 @@ namespace WixTest.WixUnitTest | |||
386 | public int LastErrorNumber { get; set; } | 421 | public int LastErrorNumber { get; set; } |
387 | 422 | ||
388 | public bool ShowVerboseMessages { get; set; } | 423 | public bool ShowVerboseMessages { get; set; } |
424 | |||
389 | public bool SuppressAllWarnings { get; set; } | 425 | public bool SuppressAllWarnings { get; set; } |
426 | |||
390 | public bool WarningsAsError { get; set; } | 427 | public bool WarningsAsError { get; set; } |
391 | 428 | ||
392 | public void ElevateWarningMessage(int warningNumber) | 429 | public void ElevateWarningMessage(int warningNumber) |
393 | { | 430 | { |
394 | } | 431 | } |
395 | 432 | ||
396 | public string FormatMessage(Message message) | 433 | public string FormatMessage(Message message) => String.Empty; |
397 | { | ||
398 | return ""; | ||
399 | } | ||
400 | 434 | ||
401 | public void SetListener(IMessageListener listener) | 435 | public void SetListener(IMessageListener listener) |
402 | { | 436 | { |
diff --git a/src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs b/src/test/WixToolsetTest.WixCop/TestData/Preprocessor/ConvertedPreprocessor.wxs index d6280185..d6280185 100644 --- a/src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs +++ b/src/test/WixToolsetTest.WixCop/TestData/Preprocessor/ConvertedPreprocessor.wxs | |||
diff --git a/src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs b/src/test/WixToolsetTest.WixCop/TestData/Preprocessor/Preprocessor.wxs index 2eb908c2..2eb908c2 100644 --- a/src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs +++ b/src/test/WixToolsetTest.WixCop/TestData/Preprocessor/Preprocessor.wxs | |||
diff --git a/src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml b/src/test/WixToolsetTest.WixCop/TestData/Preprocessor/wixcop.settings.xml index 9d3ad496..9d3ad496 100644 --- a/src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml +++ b/src/test/WixToolsetTest.WixCop/TestData/Preprocessor/wixcop.settings.xml | |||
diff --git a/src/test/wixcop/TestData/SingleFile/ConvertedSingleFile.wxs b/src/test/WixToolsetTest.WixCop/TestData/SingleFile/ConvertedSingleFile.wxs index aacb68fa..aacb68fa 100644 --- a/src/test/wixcop/TestData/SingleFile/ConvertedSingleFile.wxs +++ b/src/test/WixToolsetTest.WixCop/TestData/SingleFile/ConvertedSingleFile.wxs | |||
diff --git a/src/test/wixcop/TestData/SingleFile/SingleFile.wxs b/src/test/WixToolsetTest.WixCop/TestData/SingleFile/SingleFile.wxs index 310ae811..310ae811 100644 --- a/src/test/wixcop/TestData/SingleFile/SingleFile.wxs +++ b/src/test/WixToolsetTest.WixCop/TestData/SingleFile/SingleFile.wxs | |||
diff --git a/src/test/wixcop/WixCopFixture.cs b/src/test/WixToolsetTest.WixCop/WixCopFixture.cs index 1fa49be9..1025eac8 100644 --- a/src/test/wixcop/WixCopFixture.cs +++ b/src/test/WixToolsetTest.WixCop/WixCopFixture.cs | |||
@@ -1,18 +1,11 @@ | |||
1 | using System; | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
2 | using System.Collections.Generic; | 2 | |
3 | using System.IO; | 3 | namespace WixToolsetTest.WixCop |
4 | using System.Linq; | ||
5 | using WixBuildTools.TestSupport; | ||
6 | using WixCop.CommandLine; | ||
7 | using WixCop.Interfaces; | ||
8 | using WixToolset.Core; | ||
9 | using WixToolset.Core.TestPackage; | ||
10 | using WixToolset.Extensibility; | ||
11 | using WixToolset.Extensibility.Services; | ||
12 | using Xunit; | ||
13 | |||
14 | namespace WixCopTests | ||
15 | { | 4 | { |
5 | using System.IO; | ||
6 | using WixBuildTools.TestSupport; | ||
7 | using Xunit; | ||
8 | |||
16 | public class WixCopFixture | 9 | public class WixCopFixture |
17 | { | 10 | { |
18 | [Fact] | 11 | [Fact] |
@@ -37,13 +30,18 @@ namespace WixCopTests | |||
37 | }, | 30 | }, |
38 | }; | 31 | }; |
39 | 32 | ||
40 | var result = runner.Execute(out var messages); | 33 | var result = runner.Execute(); |
41 | 34 | ||
42 | Assert.Equal(2, result); | 35 | Assert.Equal(2, result.ExitCode); |
43 | 36 | ||
44 | var actualLines = File.ReadAllLines(targetFile); | 37 | var actualLines = File.ReadAllLines(targetFile); |
45 | var expectedLines = File.ReadAllLines(Path.Combine(folder, afterFileName)); | 38 | var expectedLines = File.ReadAllLines(Path.Combine(folder, afterFileName)); |
46 | Assert.Equal(expectedLines, actualLines); | 39 | |
40 | for (var i = 0; i < actualLines.Length && i < expectedLines.Length; ++i) | ||
41 | { | ||
42 | Assert.Equal(expectedLines[i], actualLines[i]); | ||
43 | } | ||
44 | Assert.Equal(expectedLines.Length, actualLines.Length); | ||
47 | 45 | ||
48 | var runner2 = new WixCopRunner | 46 | var runner2 = new WixCopRunner |
49 | { | 47 | { |
@@ -54,9 +52,9 @@ namespace WixCopTests | |||
54 | }, | 52 | }, |
55 | }; | 53 | }; |
56 | 54 | ||
57 | var result2 = runner2.Execute(out var messages2); | 55 | var result2 = runner2.Execute(); |
58 | 56 | ||
59 | Assert.Equal(0, result2); | 57 | Assert.Equal(0, result2.ExitCode); |
60 | } | 58 | } |
61 | } | 59 | } |
62 | 60 | ||
@@ -83,9 +81,9 @@ namespace WixCopTests | |||
83 | }, | 81 | }, |
84 | }; | 82 | }; |
85 | 83 | ||
86 | var result = runner.Execute(out var messages); | 84 | var result = runner.Execute(); |
87 | 85 | ||
88 | Assert.Equal(2, result); | 86 | Assert.Equal(2, result.ExitCode); |
89 | 87 | ||
90 | var actualLines = File.ReadAllLines(targetFile); | 88 | var actualLines = File.ReadAllLines(targetFile); |
91 | var expectedLines = File.ReadAllLines(Path.Combine(folder, afterFileName)); | 89 | var expectedLines = File.ReadAllLines(Path.Combine(folder, afterFileName)); |
@@ -101,61 +99,9 @@ namespace WixCopTests | |||
101 | }, | 99 | }, |
102 | }; | 100 | }; |
103 | 101 | ||
104 | var result2 = runner2.Execute(out var messages2); | 102 | var result2 = runner2.Execute(); |
105 | |||
106 | Assert.Equal(0, result2); | ||
107 | } | ||
108 | } | ||
109 | 103 | ||
110 | private class WixCopRunner | 104 | Assert.Equal(0, result2.ExitCode); |
111 | { | ||
112 | public bool FixErrors { get; set; } | ||
113 | |||
114 | public List<string> SearchPatterns { get; } = new List<string>(); | ||
115 | |||
116 | public string SettingFile1 { get; set; } | ||
117 | |||
118 | public int Execute(out List<string> messages) | ||
119 | { | ||
120 | var argList = new List<string>(); | ||
121 | |||
122 | if (this.FixErrors) | ||
123 | { | ||
124 | argList.Add("-f"); | ||
125 | } | ||
126 | |||
127 | if (!String.IsNullOrEmpty(this.SettingFile1)) | ||
128 | { | ||
129 | argList.Add($"-set1{this.SettingFile1}"); | ||
130 | } | ||
131 | |||
132 | foreach (string searchPattern in this.SearchPatterns) | ||
133 | { | ||
134 | argList.Add(searchPattern); | ||
135 | } | ||
136 | |||
137 | return WixCopRunner.Execute(argList.ToArray(), out messages); | ||
138 | } | ||
139 | |||
140 | public static int Execute(string[] args, out List<string> messages) | ||
141 | { | ||
142 | var listener = new TestMessageListener(); | ||
143 | |||
144 | var serviceProvider = new WixToolsetServiceProvider(); | ||
145 | serviceProvider.AddService<IMessageListener>((x, y) => listener); | ||
146 | serviceProvider.AddService<IWixCopCommandLineParser>((x, y) => new WixCopCommandLineParser(x)); | ||
147 | |||
148 | var result = Execute(serviceProvider, args); | ||
149 | |||
150 | var messaging = serviceProvider.GetService<IMessaging>(); | ||
151 | messages = listener.Messages.Select(x => messaging.FormatMessage(x)).ToList(); | ||
152 | return result; | ||
153 | } | ||
154 | |||
155 | public static int Execute(IServiceProvider serviceProvider, string[] args) | ||
156 | { | ||
157 | var wixcop = new WixCop.Program(); | ||
158 | return wixcop.Run(serviceProvider, args); | ||
159 | } | 105 | } |
160 | } | 106 | } |
161 | } | 107 | } |
diff --git a/src/test/WixToolsetTest.WixCop/WixCopRunner.cs b/src/test/WixToolsetTest.WixCop/WixCopRunner.cs new file mode 100644 index 00000000..b831baa7 --- /dev/null +++ b/src/test/WixToolsetTest.WixCop/WixCopRunner.cs | |||
@@ -0,0 +1,67 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolsetTest.WixCop | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using WixToolset.Core; | ||
8 | using WixToolset.Core.TestPackage; | ||
9 | using WixToolset.Extensibility; | ||
10 | using WixToolset.Tools.WixCop; | ||
11 | using WixToolset.Tools.WixCop.CommandLine; | ||
12 | using WixToolset.Tools.WixCop.Interfaces; | ||
13 | |||
14 | public class WixCopRunner | ||
15 | { | ||
16 | public bool FixErrors { get; set; } | ||
17 | |||
18 | public List<string> SearchPatterns { get; } = new List<string>(); | ||
19 | |||
20 | public string SettingFile1 { get; set; } | ||
21 | |||
22 | public WixCopRunnerResult Execute() | ||
23 | { | ||
24 | var argList = new List<string>(); | ||
25 | |||
26 | if (this.FixErrors) | ||
27 | { | ||
28 | argList.Add("-f"); | ||
29 | } | ||
30 | |||
31 | if (!String.IsNullOrEmpty(this.SettingFile1)) | ||
32 | { | ||
33 | argList.Add($"-set1{this.SettingFile1}"); | ||
34 | } | ||
35 | |||
36 | foreach (var searchPattern in this.SearchPatterns) | ||
37 | { | ||
38 | argList.Add(searchPattern); | ||
39 | } | ||
40 | |||
41 | return WixCopRunner.Execute(argList.ToArray()); | ||
42 | } | ||
43 | |||
44 | public static WixCopRunnerResult Execute(string[] args) | ||
45 | { | ||
46 | var listener = new TestMessageListener(); | ||
47 | |||
48 | var serviceProvider = new WixToolsetServiceProvider(); | ||
49 | serviceProvider.AddService<IMessageListener>((x, y) => listener); | ||
50 | serviceProvider.AddService<IWixCopCommandLineParser>((x, y) => new WixCopCommandLineParser(x)); | ||
51 | |||
52 | var exitCode = Execute(serviceProvider, args); | ||
53 | |||
54 | return new WixCopRunnerResult | ||
55 | { | ||
56 | ExitCode = exitCode, | ||
57 | Messages = listener.Messages.ToArray() | ||
58 | }; | ||
59 | } | ||
60 | |||
61 | public static int Execute(IServiceProvider serviceProvider, string[] args) | ||
62 | { | ||
63 | var wixcop = new Program(); | ||
64 | return wixcop.Run(serviceProvider, args); | ||
65 | } | ||
66 | } | ||
67 | } | ||
diff --git a/src/test/WixToolsetTest.WixCop/WixCopRunnerResult.cs b/src/test/WixToolsetTest.WixCop/WixCopRunnerResult.cs new file mode 100644 index 00000000..1b35e491 --- /dev/null +++ b/src/test/WixToolsetTest.WixCop/WixCopRunnerResult.cs | |||
@@ -0,0 +1,22 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolsetTest.WixCop | ||
4 | { | ||
5 | using System; | ||
6 | using System.Linq; | ||
7 | using WixToolset.Data; | ||
8 | using Xunit; | ||
9 | |||
10 | public class WixCopRunnerResult | ||
11 | { | ||
12 | public int ExitCode { get; set; } | ||
13 | |||
14 | public Message[] Messages { get; set; } | ||
15 | |||
16 | public WixCopRunnerResult AssertSuccess() | ||
17 | { | ||
18 | Assert.True(0 == this.ExitCode, $"WixCop failed unexpectedly. Output:\r\n{String.Join("\r\n", this.Messages.Select(m => m.ToString()).ToArray())}"); | ||
19 | return this; | ||
20 | } | ||
21 | } | ||
22 | } | ||
diff --git a/src/test/wixcop/WixCopTests.csproj b/src/test/WixToolsetTest.WixCop/WixToolsetTest.WixCop.csproj index 012ef4db..6b41b6b6 100644 --- a/src/test/wixcop/WixCopTests.csproj +++ b/src/test/WixToolsetTest.WixCop/WixToolsetTest.WixCop.csproj | |||
@@ -7,6 +7,7 @@ | |||
7 | <IsPackable>false</IsPackable> | 7 | <IsPackable>false</IsPackable> |
8 | <DebugType>embedded</DebugType> | 8 | <DebugType>embedded</DebugType> |
9 | </PropertyGroup> | 9 | </PropertyGroup> |
10 | |||
10 | <ItemGroup> | 11 | <ItemGroup> |
11 | <None Remove="TestData\SingleFile\ConvertedSingleFile.wxs" /> | 12 | <None Remove="TestData\SingleFile\ConvertedSingleFile.wxs" /> |
12 | <None Remove="TestData\SingleFile\SingleFile.wxs" /> | 13 | <None Remove="TestData\SingleFile\SingleFile.wxs" /> |