diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs b/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs new file mode 100644 index 00000000..d9c58160 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs | |||
@@ -0,0 +1,79 @@ | |||
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 UtilExtensionFixture : BaseConverterFixture | ||
12 | { | ||
13 | [Fact] | ||
14 | public void FixCloseAppsCondition() | ||
15 | { | ||
16 | var parse = String.Join(Environment.NewLine, | ||
17 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", | ||
18 | " <Fragment>", | ||
19 | " <util:CloseApplication Id='EndApp' Target='example.exe'>", | ||
20 | " a<>b", | ||
21 | " </util:CloseApplication>", | ||
22 | " </Fragment>", | ||
23 | "</Wix>"); | ||
24 | |||
25 | var expected = new[] | ||
26 | { | ||
27 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | ||
28 | " <Fragment>", | ||
29 | " <util:CloseApplication Id=\"EndApp\" Target=\"example.exe\" Condition=\"a<>b\" />", | ||
30 | " </Fragment>", | ||
31 | "</Wix>" | ||
32 | }; | ||
33 | |||
34 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
35 | |||
36 | var messaging = new MockMessaging(); | ||
37 | var converter = new WixConverter(messaging, 2, null, null); | ||
38 | |||
39 | var errors = converter.ConvertDocument(document); | ||
40 | Assert.Equal(3, errors); | ||
41 | |||
42 | var actualLines = UnformattedDocumentLines(document); | ||
43 | CompareLineByLine(expected, actualLines); | ||
44 | } | ||
45 | |||
46 | [Fact] | ||
47 | public void FixXmlConfigValue() | ||
48 | { | ||
49 | var parse = String.Join(Environment.NewLine, | ||
50 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", | ||
51 | " <Fragment>", | ||
52 | " <util:XmlConfig Id='Change' ElementPath='book'>", | ||
53 | " a<>b", | ||
54 | " </util:XmlConfig>", | ||
55 | " </Fragment>", | ||
56 | "</Wix>"); | ||
57 | |||
58 | var expected = new[] | ||
59 | { | ||
60 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | ||
61 | " <Fragment>", | ||
62 | " <util:XmlConfig Id=\"Change\" ElementPath=\"book\" Value=\"a<>b\" />", | ||
63 | " </Fragment>", | ||
64 | "</Wix>" | ||
65 | }; | ||
66 | |||
67 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
68 | |||
69 | var messaging = new MockMessaging(); | ||
70 | var converter = new WixConverter(messaging, 2, null, null); | ||
71 | |||
72 | var errors = converter.ConvertDocument(document); | ||
73 | Assert.Equal(3, errors); | ||
74 | |||
75 | var actualLines = UnformattedDocumentLines(document); | ||
76 | CompareLineByLine(expected, actualLines); | ||
77 | } | ||
78 | } | ||
79 | } | ||