@joebigelow / wix-1 / commits / f0544d8b

Ensure Include elements have correct namespace

Fixes wixtoolset/issues#5891

Rob Mensching committed Jun 26, 2020 at 14:04 UTC f0544d8b04951ea0c9ccd03bcdd8284a96bc569c
1 file changed +67
src/test/WixToolsetTest.Converters/IncludeFixture.cs new
+67
@@ -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.Converters
4 +{
5 + using System;
6 + using System.Xml.Linq;
7 + using WixToolset.Converters;
8 + using WixToolsetTest.Converters.Mocks;
9 + using Xunit;
10 +
11 + public class IncludeFixture : BaseConverterFixture
12 + {
13 + [Fact]
14 + public void EnsureNamespace()
15 + {
16 + var parse = String.Join(Environment.NewLine,
17 + "<Include>",
18 + " <Fragment />",
19 + "</Include>");
20 +
21 + var expected = new[]
22 + {
23 + "<Include xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
24 + " <Fragment />",
25 + "</Include>"
26 + };
27 +
28 + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
29 +
30 + var messaging = new MockMessaging();
31 + var converter = new WixConverter(messaging, 2, null, null);
32 +
33 + var errors = converter.ConvertDocument(document);
34 + Assert.Equal(1, errors);
35 +
36 + var actualLines = UnformattedDocumentLines(document);
37 + CompareLineByLine(expected, actualLines);
38 + }
39 +
40 + [Fact]
41 + public void FixNamespace()
42 + {
43 + var parse = String.Join(Environment.NewLine,
44 + "<Include xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
45 + " <Fragment />",
46 + "</Include>");
47 +
48 + var expected = new[]
49 + {
50 + "<Include xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
51 + " <Fragment />",
52 + "</Include>"
53 + };
54 +
55 + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
56 +
57 + var messaging = new MockMessaging();
58 + var converter = new WixConverter(messaging, 2, null, null);
59 +
60 + var errors = converter.ConvertDocument(document);
61 + Assert.Equal(1, errors);
62 +
63 + var actualLines = UnformattedDocumentLines(document);
64 + CompareLineByLine(expected, actualLines);
65 + }
66 + }
67 +}