diff options
Diffstat (limited to 'src/test/WixToolsetTest.Converters/PropertyFixture.cs')
-rw-r--r-- | src/test/WixToolsetTest.Converters/PropertyFixture.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.Converters/PropertyFixture.cs b/src/test/WixToolsetTest.Converters/PropertyFixture.cs new file mode 100644 index 00000000..0449fb43 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/PropertyFixture.cs | |||
@@ -0,0 +1,114 @@ | |||
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 PropertyFixture : BaseConverterFixture | ||
12 | { | ||
13 | [Fact] | ||
14 | public void CanFixCdataWhitespace() | ||
15 | { | ||
16 | var parse = String.Join(Environment.NewLine, | ||
17 | "<?xml version='1.0' encoding='utf-8'?>", | ||
18 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
19 | " <Fragment>", | ||
20 | " <Property Id='Prop'>", | ||
21 | " <![CDATA[1<2]]>", | ||
22 | " </Property>", | ||
23 | " </Fragment>", | ||
24 | "</Wix>"); | ||
25 | |||
26 | var expected = String.Join(Environment.NewLine, | ||
27 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
28 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
29 | " <Fragment>", | ||
30 | " <Property Id=\"Prop\" Value=\"1<2\" />", | ||
31 | " </Fragment>", | ||
32 | "</Wix>"); | ||
33 | |||
34 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
35 | |||
36 | var messaging = new MockMessaging(); | ||
37 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
38 | |||
39 | var errors = converter.ConvertDocument(document); | ||
40 | |||
41 | var actual = UnformattedDocumentString(document); | ||
42 | |||
43 | Assert.Equal(expected, actual); | ||
44 | Assert.Equal(1, errors); | ||
45 | } | ||
46 | |||
47 | [Fact] | ||
48 | public void CanFixCdataWithWhitespace() | ||
49 | { | ||
50 | var parse = String.Join(Environment.NewLine, | ||
51 | "<?xml version='1.0' encoding='utf-8'?>", | ||
52 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
53 | " <Fragment>", | ||
54 | " <Property Id='Prop'>", | ||
55 | " <![CDATA[", | ||
56 | " 1<2", | ||
57 | " ]]>", | ||
58 | " </Property>", | ||
59 | " </Fragment>", | ||
60 | "</Wix>"); | ||
61 | |||
62 | var expected = String.Join(Environment.NewLine, | ||
63 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
64 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
65 | " <Fragment>", | ||
66 | " <Property Id=\"Prop\" Value=\"1<2\" />", | ||
67 | " </Fragment>", | ||
68 | "</Wix>"); | ||
69 | |||
70 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
71 | |||
72 | var messaging = new MockMessaging(); | ||
73 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
74 | |||
75 | var errors = converter.ConvertDocument(document); | ||
76 | |||
77 | var actual = UnformattedDocumentString(document); | ||
78 | |||
79 | Assert.Equal(expected, actual); | ||
80 | Assert.Equal(1, errors); | ||
81 | } | ||
82 | |||
83 | [Fact] | ||
84 | public void CanKeepCdataWithOnlyWhitespace() | ||
85 | { | ||
86 | var parse = String.Join(Environment.NewLine, | ||
87 | "<?xml version='1.0' encoding='utf-8'?>", | ||
88 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
89 | " <Fragment>", | ||
90 | " <Property Id='Prop'><![CDATA[ ]]></Property>", | ||
91 | " </Fragment>", | ||
92 | "</Wix>"); | ||
93 | |||
94 | var expected = String.Join(Environment.NewLine, | ||
95 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
96 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
97 | " <Fragment>", | ||
98 | " <Property Id=\"Prop\" Value=\" \" />", | ||
99 | " </Fragment>", | ||
100 | "</Wix>"); | ||
101 | |||
102 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
103 | |||
104 | var messaging = new MockMessaging(); | ||
105 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
106 | var errors = converter.ConvertDocument(document); | ||
107 | |||
108 | var actual = UnformattedDocumentString(document); | ||
109 | |||
110 | Assert.Equal(expected, actual); | ||
111 | Assert.Equal(1, errors); | ||
112 | } | ||
113 | } | ||
114 | } | ||