diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/WixToolsetTest.WixCop/ConverterFixture.cs | 554 |
1 files changed, 0 insertions, 554 deletions
diff --git a/src/test/WixToolsetTest.WixCop/ConverterFixture.cs b/src/test/WixToolsetTest.WixCop/ConverterFixture.cs deleted file mode 100644 index ceac07d6..00000000 --- a/src/test/WixToolsetTest.WixCop/ConverterFixture.cs +++ /dev/null | |||
@@ -1,554 +0,0 @@ | |||
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.IO; | ||
7 | using System.Text; | ||
8 | using System.Xml.Linq; | ||
9 | using WixToolset.Data; | ||
10 | using WixToolset.Extensibility; | ||
11 | using WixToolset.Extensibility.Services; | ||
12 | using WixToolset.Tools.WixCop; | ||
13 | using Xunit; | ||
14 | |||
15 | public class ConverterFixture | ||
16 | { | ||
17 | private static readonly XNamespace Wix4Namespace = "http://wixtoolset.org/schemas/v4/wxs"; | ||
18 | |||
19 | [Fact] | ||
20 | public void EnsuresDeclaration() | ||
21 | { | ||
22 | var parse = String.Join(Environment.NewLine, | ||
23 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
24 | " <Fragment />", | ||
25 | "</Wix>"); | ||
26 | |||
27 | var expected = String.Join(Environment.NewLine, | ||
28 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
29 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
30 | " <Fragment />", | ||
31 | "</Wix>"); | ||
32 | |||
33 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
34 | |||
35 | var messaging = new DummyMessaging(); | ||
36 | var converter = new Converter(messaging, 2, null, null); | ||
37 | |||
38 | var errors = converter.ConvertDocument(document); | ||
39 | |||
40 | var actual = UnformattedDocumentString(document); | ||
41 | |||
42 | Assert.Equal(1, errors); | ||
43 | Assert.Equal(expected, actual); | ||
44 | } | ||
45 | |||
46 | [Fact] | ||
47 | public void EnsuresUtf8Declaration() | ||
48 | { | ||
49 | var parse = String.Join(Environment.NewLine, | ||
50 | "<?xml version='1.0'?>", | ||
51 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
52 | " <Fragment />", | ||
53 | "</Wix>"); | ||
54 | |||
55 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
56 | |||
57 | var messaging = new DummyMessaging(); | ||
58 | var converter = new Converter(messaging, 4, null, null); | ||
59 | |||
60 | var errors = converter.ConvertDocument(document); | ||
61 | |||
62 | Assert.Equal(1, errors); | ||
63 | Assert.Equal("1.0", document.Declaration.Version); | ||
64 | Assert.Equal("utf-8", document.Declaration.Encoding); | ||
65 | } | ||
66 | |||
67 | [Fact] | ||
68 | public void CanFixWhitespace() | ||
69 | { | ||
70 | var parse = String.Join(Environment.NewLine, | ||
71 | "<?xml version='1.0' encoding='utf-8'?>", | ||
72 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
73 | " <Fragment>", | ||
74 | " <Property Id='Prop'", | ||
75 | " Value='Val'>", | ||
76 | " </Property>", | ||
77 | " </Fragment>", | ||
78 | "</Wix>"); | ||
79 | |||
80 | var expected = String.Join(Environment.NewLine, | ||
81 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
82 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
83 | " <Fragment>", | ||
84 | " <Property Id=\"Prop\" Value=\"Val\" />", | ||
85 | " </Fragment>", | ||
86 | "</Wix>"); | ||
87 | |||
88 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
89 | |||
90 | var messaging = new DummyMessaging(); | ||
91 | var converter = new Converter(messaging, 4, null, null); | ||
92 | |||
93 | var errors = converter.ConvertDocument(document); | ||
94 | |||
95 | var actual = UnformattedDocumentString(document); | ||
96 | |||
97 | Assert.Equal(expected, actual); | ||
98 | Assert.Equal(4, errors); | ||
99 | } | ||
100 | |||
101 | [Fact] | ||
102 | public void CanPreserveNewLines() | ||
103 | { | ||
104 | var parse = String.Join(Environment.NewLine, | ||
105 | "<?xml version='1.0' encoding='utf-8'?>", | ||
106 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
107 | " <Fragment>", | ||
108 | "", | ||
109 | " <Property Id='Prop' Value='Val' />", | ||
110 | "", | ||
111 | " </Fragment>", | ||
112 | "</Wix>"); | ||
113 | |||
114 | var expected = String.Join(Environment.NewLine, | ||
115 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
116 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
117 | " <Fragment>", | ||
118 | "", | ||
119 | " <Property Id=\"Prop\" Value=\"Val\" />", | ||
120 | "", | ||
121 | " </Fragment>", | ||
122 | "</Wix>"); | ||
123 | |||
124 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
125 | |||
126 | var messaging = new DummyMessaging(); | ||
127 | var converter = new Converter(messaging, 4, null, null); | ||
128 | |||
129 | var conversions = converter.ConvertDocument(document); | ||
130 | |||
131 | var actual = UnformattedDocumentString(document); | ||
132 | |||
133 | Assert.Equal(expected, actual); | ||
134 | Assert.Equal(3, conversions); | ||
135 | } | ||
136 | |||
137 | [Fact] | ||
138 | public void CanConvertWithNewLineAtEndOfFile() | ||
139 | { | ||
140 | var parse = String.Join(Environment.NewLine, | ||
141 | "<?xml version='1.0' encoding='utf-8'?>", | ||
142 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
143 | " <Fragment>", | ||
144 | "", | ||
145 | " <Property Id='Prop' Value='Val' />", | ||
146 | "", | ||
147 | " </Fragment>", | ||
148 | "</Wix>", | ||
149 | ""); | ||
150 | |||
151 | var expected = String.Join(Environment.NewLine, | ||
152 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
153 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
154 | " <Fragment>", | ||
155 | "", | ||
156 | " <Property Id=\"Prop\" Value=\"Val\" />", | ||
157 | "", | ||
158 | " </Fragment>", | ||
159 | "</Wix>", | ||
160 | ""); | ||
161 | |||
162 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
163 | |||
164 | var messaging = new DummyMessaging(); | ||
165 | var converter = new Converter(messaging, 4, null, null); | ||
166 | |||
167 | var conversions = converter.ConvertDocument(document); | ||
168 | |||
169 | var actual = UnformattedDocumentString(document); | ||
170 | |||
171 | Assert.Equal(expected, actual); | ||
172 | Assert.Equal(3, conversions); | ||
173 | } | ||
174 | |||
175 | [Fact] | ||
176 | public void CanFixCdataWhitespace() | ||
177 | { | ||
178 | var parse = String.Join(Environment.NewLine, | ||
179 | "<?xml version='1.0' encoding='utf-8'?>", | ||
180 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
181 | " <Fragment>", | ||
182 | " <Property Id='Prop'>", | ||
183 | " <![CDATA[1<2]]>", | ||
184 | " </Property>", | ||
185 | " </Fragment>", | ||
186 | "</Wix>"); | ||
187 | |||
188 | var expected = String.Join(Environment.NewLine, | ||
189 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
190 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
191 | " <Fragment>", | ||
192 | " <Property Id=\"Prop\"><![CDATA[1<2]]></Property>", | ||
193 | " </Fragment>", | ||
194 | "</Wix>"); | ||
195 | |||
196 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
197 | |||
198 | var messaging = new DummyMessaging(); | ||
199 | var converter = new Converter(messaging, 2, null, null); | ||
200 | |||
201 | var errors = converter.ConvertDocument(document); | ||
202 | |||
203 | var actual = UnformattedDocumentString(document); | ||
204 | |||
205 | Assert.Equal(expected, actual); | ||
206 | Assert.Equal(2, errors); | ||
207 | } | ||
208 | |||
209 | [Fact] | ||
210 | public void CanFixCdataWithWhitespace() | ||
211 | { | ||
212 | var parse = String.Join(Environment.NewLine, | ||
213 | "<?xml version='1.0' encoding='utf-8'?>", | ||
214 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
215 | " <Fragment>", | ||
216 | " <Property Id='Prop'>", | ||
217 | " <![CDATA[", | ||
218 | " 1<2", | ||
219 | " ]]>", | ||
220 | " </Property>", | ||
221 | " </Fragment>", | ||
222 | "</Wix>"); | ||
223 | |||
224 | var expected = String.Join(Environment.NewLine, | ||
225 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
226 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
227 | " <Fragment>", | ||
228 | " <Property Id=\"Prop\"><![CDATA[1<2]]></Property>", | ||
229 | " </Fragment>", | ||
230 | "</Wix>"); | ||
231 | |||
232 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
233 | |||
234 | var messaging = new DummyMessaging(); | ||
235 | var converter = new Converter(messaging, 2, null, null); | ||
236 | |||
237 | var errors = converter.ConvertDocument(document); | ||
238 | |||
239 | var actual = UnformattedDocumentString(document); | ||
240 | |||
241 | Assert.Equal(expected, actual); | ||
242 | Assert.Equal(2, errors); | ||
243 | } | ||
244 | |||
245 | [Fact] | ||
246 | public void CanConvertMainNamespace() | ||
247 | { | ||
248 | var parse = String.Join(Environment.NewLine, | ||
249 | "<?xml version='1.0' encoding='utf-8'?>", | ||
250 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
251 | " <Fragment />", | ||
252 | "</Wix>"); | ||
253 | |||
254 | var expected = String.Join(Environment.NewLine, | ||
255 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
256 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
257 | " <Fragment />", | ||
258 | "</Wix>"); | ||
259 | |||
260 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
261 | |||
262 | var messaging = new DummyMessaging(); | ||
263 | var converter = new Converter(messaging, 2, null, null); | ||
264 | |||
265 | var errors = converter.ConvertDocument(document); | ||
266 | |||
267 | var actual = UnformattedDocumentString(document); | ||
268 | |||
269 | Assert.Equal(1, errors); | ||
270 | //Assert.Equal(Wix4Namespace, document.Root.GetDefaultNamespace()); | ||
271 | Assert.Equal(expected, actual); | ||
272 | } | ||
273 | |||
274 | [Fact] | ||
275 | public void CanConvertNamedMainNamespace() | ||
276 | { | ||
277 | var parse = String.Join(Environment.NewLine, | ||
278 | "<?xml version='1.0' encoding='utf-8'?>", | ||
279 | "<w:Wix xmlns:w='http://schemas.microsoft.com/wix/2006/wi'>", | ||
280 | " <w:Fragment />", | ||
281 | "</w:Wix>"); | ||
282 | |||
283 | var expected = String.Join(Environment.NewLine, | ||
284 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
285 | "<w:Wix xmlns:w=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
286 | " <w:Fragment />", | ||
287 | "</w:Wix>"); | ||
288 | |||
289 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
290 | |||
291 | var messaging = new DummyMessaging(); | ||
292 | var converter = new Converter(messaging, 2, null, null); | ||
293 | |||
294 | var errors = converter.ConvertDocument(document); | ||
295 | |||
296 | var actual = UnformattedDocumentString(document); | ||
297 | |||
298 | Assert.Equal(1, errors); | ||
299 | Assert.Equal(expected, actual); | ||
300 | Assert.Equal(Wix4Namespace, document.Root.GetNamespaceOfPrefix("w")); | ||
301 | } | ||
302 | |||
303 | [Fact] | ||
304 | public void CanConvertNonWixDefaultNamespace() | ||
305 | { | ||
306 | var parse = String.Join(Environment.NewLine, | ||
307 | "<?xml version='1.0' encoding='utf-8'?>", | ||
308 | "<w:Wix xmlns:w='http://schemas.microsoft.com/wix/2006/wi' xmlns='http://schemas.microsoft.com/wix/UtilExtension'>", | ||
309 | " <w:Fragment>", | ||
310 | " <Test />", | ||
311 | " </w:Fragment>", | ||
312 | "</w:Wix>"); | ||
313 | |||
314 | var expected = String.Join(Environment.NewLine, | ||
315 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
316 | "<w:Wix xmlns:w=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | ||
317 | " <w:Fragment>", | ||
318 | " <Test />", | ||
319 | " </w:Fragment>", | ||
320 | "</w:Wix>"); | ||
321 | |||
322 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
323 | |||
324 | var messaging = new DummyMessaging(); | ||
325 | var converter = new Converter(messaging, 2, null, null); | ||
326 | |||
327 | var errors = converter.ConvertDocument(document); | ||
328 | |||
329 | var actual = UnformattedDocumentString(document); | ||
330 | |||
331 | Assert.Equal(expected, actual); | ||
332 | Assert.Equal(2, errors); | ||
333 | Assert.Equal(Wix4Namespace, document.Root.GetNamespaceOfPrefix("w")); | ||
334 | Assert.Equal("http://wixtoolset.org/schemas/v4/wxs/util", document.Root.GetDefaultNamespace()); | ||
335 | } | ||
336 | |||
337 | [Fact] | ||
338 | public void CanConvertExtensionNamespace() | ||
339 | { | ||
340 | var parse = String.Join(Environment.NewLine, | ||
341 | "<?xml version='1.0' encoding='utf-8'?>", | ||
342 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", | ||
343 | " <Fragment />", | ||
344 | "</Wix>"); | ||
345 | |||
346 | var expected = String.Join(Environment.NewLine, | ||
347 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
348 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | ||
349 | " <Fragment />", | ||
350 | "</Wix>"); | ||
351 | |||
352 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
353 | |||
354 | var messaging = new DummyMessaging(); | ||
355 | var converter = new Converter(messaging, 2, null, null); | ||
356 | |||
357 | var errors = converter.ConvertDocument(document); | ||
358 | |||
359 | var actual = UnformattedDocumentString(document); | ||
360 | |||
361 | Assert.Equal(2, errors); | ||
362 | Assert.Equal(expected, actual); | ||
363 | Assert.Equal(Wix4Namespace, document.Root.GetDefaultNamespace()); | ||
364 | } | ||
365 | |||
366 | [Fact] | ||
367 | public void CanConvertMissingNamespace() | ||
368 | { | ||
369 | var parse = String.Join(Environment.NewLine, | ||
370 | "<?xml version='1.0' encoding='utf-8'?>", | ||
371 | "<Wix>", | ||
372 | " <Fragment />", | ||
373 | "</Wix>"); | ||
374 | |||
375 | var expected = String.Join(Environment.NewLine, | ||
376 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
377 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
378 | " <Fragment />", | ||
379 | "</Wix>"); | ||
380 | |||
381 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
382 | |||
383 | var messaging = new DummyMessaging(); | ||
384 | var converter = new Converter(messaging, 2, null, null); | ||
385 | |||
386 | var errors = converter.ConvertDocument(document); | ||
387 | |||
388 | var actual = UnformattedDocumentString(document); | ||
389 | |||
390 | Assert.Equal(1, errors); | ||
391 | Assert.Equal(expected, actual); | ||
392 | Assert.Equal(Wix4Namespace, document.Root.GetDefaultNamespace()); | ||
393 | } | ||
394 | |||
395 | [Fact] | ||
396 | public void CanConvertAnonymousFile() | ||
397 | { | ||
398 | var parse = String.Join(Environment.NewLine, | ||
399 | "<?xml version='1.0' encoding='utf-8'?>", | ||
400 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
401 | " <File Source='path\\to\\foo.txt' />", | ||
402 | "</Wix>"); | ||
403 | |||
404 | var expected = String.Join(Environment.NewLine, | ||
405 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
406 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
407 | " <File Id=\"foo.txt\" Source=\"path\\to\\foo.txt\" />", | ||
408 | "</Wix>"); | ||
409 | |||
410 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
411 | |||
412 | var messaging = new DummyMessaging(); | ||
413 | var converter = new Converter(messaging, 2, null, null); | ||
414 | |||
415 | var errors = converter.ConvertDocument(document); | ||
416 | |||
417 | var actual = UnformattedDocumentString(document); | ||
418 | |||
419 | Assert.Equal(1, errors); | ||
420 | Assert.Equal(expected, actual); | ||
421 | } | ||
422 | |||
423 | [Fact] | ||
424 | public void CanConvertShortNameDirectoryWithoutName() | ||
425 | { | ||
426 | var parse = String.Join(Environment.NewLine, | ||
427 | "<?xml version='1.0' encoding='utf-8'?>", | ||
428 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
429 | " <Directory ShortName='iamshort' />", | ||
430 | "</Wix>"); | ||
431 | |||
432 | var expected = String.Join(Environment.NewLine, | ||
433 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
434 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
435 | " <Directory Name=\"iamshort\" />", | ||
436 | "</Wix>"); | ||
437 | |||
438 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
439 | |||
440 | var messaging = new DummyMessaging(); | ||
441 | var converter = new Converter(messaging, 2, null, null); | ||
442 | |||
443 | var errors = converter.ConvertDocument(document); | ||
444 | |||
445 | var actual = UnformattedDocumentString(document); | ||
446 | |||
447 | Assert.Equal(1, errors); | ||
448 | Assert.Equal(expected, actual); | ||
449 | } | ||
450 | |||
451 | [Fact] | ||
452 | public void CanConvertSuppressSignatureValidationNo() | ||
453 | { | ||
454 | var parse = String.Join(Environment.NewLine, | ||
455 | "<?xml version='1.0' encoding='utf-8'?>", | ||
456 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
457 | " <MsiPackage SuppressSignatureValidation='no' />", | ||
458 | "</Wix>"); | ||
459 | |||
460 | var expected = String.Join(Environment.NewLine, | ||
461 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
462 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
463 | " <MsiPackage EnableSignatureValidation=\"yes\" />", | ||
464 | "</Wix>"); | ||
465 | |||
466 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
467 | |||
468 | var messaging = new DummyMessaging(); | ||
469 | var converter = new Converter(messaging, 2, null, null); | ||
470 | |||
471 | var errors = converter.ConvertDocument(document); | ||
472 | |||
473 | var actual = UnformattedDocumentString(document); | ||
474 | |||
475 | Assert.Equal(1, errors); | ||
476 | Assert.Equal(expected, actual); | ||
477 | } | ||
478 | |||
479 | [Fact] | ||
480 | public void CanConvertSuppressSignatureValidationYes() | ||
481 | { | ||
482 | var parse = String.Join(Environment.NewLine, | ||
483 | "<?xml version='1.0' encoding='utf-8'?>", | ||
484 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
485 | " <Payload SuppressSignatureValidation='yes' />", | ||
486 | "</Wix>"); | ||
487 | |||
488 | var expected = String.Join(Environment.NewLine, | ||
489 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
490 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
491 | " <Payload />", | ||
492 | "</Wix>"); | ||
493 | |||
494 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
495 | |||
496 | var messaging = new DummyMessaging(); | ||
497 | var converter = new Converter(messaging, 2, null, null); | ||
498 | |||
499 | var errors = converter.ConvertDocument(document); | ||
500 | |||
501 | var actual = UnformattedDocumentString(document); | ||
502 | |||
503 | Assert.Equal(1, errors); | ||
504 | Assert.Equal(expected, actual); | ||
505 | } | ||
506 | |||
507 | private static string UnformattedDocumentString(XDocument document) | ||
508 | { | ||
509 | var sb = new StringBuilder(); | ||
510 | |||
511 | using (var writer = new StringWriter(sb)) | ||
512 | { | ||
513 | document.Save(writer, SaveOptions.DisableFormatting); | ||
514 | } | ||
515 | |||
516 | return sb.ToString(); | ||
517 | } | ||
518 | |||
519 | private class DummyMessaging : IMessaging | ||
520 | { | ||
521 | public bool EncounteredError { get; set; } | ||
522 | |||
523 | public int LastErrorNumber { get; set; } | ||
524 | |||
525 | public bool ShowVerboseMessages { get; set; } | ||
526 | |||
527 | public bool SuppressAllWarnings { get; set; } | ||
528 | |||
529 | public bool WarningsAsError { get; set; } | ||
530 | |||
531 | public void ElevateWarningMessage(int warningNumber) | ||
532 | { | ||
533 | } | ||
534 | |||
535 | public string FormatMessage(Message message) => String.Empty; | ||
536 | |||
537 | public void SetListener(IMessageListener listener) | ||
538 | { | ||
539 | } | ||
540 | |||
541 | public void SuppressWarningMessage(int warningNumber) | ||
542 | { | ||
543 | } | ||
544 | |||
545 | public void Write(Message message) | ||
546 | { | ||
547 | } | ||
548 | |||
549 | public void Write(string message, bool verbose = false) | ||
550 | { | ||
551 | } | ||
552 | } | ||
553 | } | ||
554 | } | ||