diff options
Diffstat (limited to 'src/test')
6 files changed, 607 insertions, 151 deletions
diff --git a/src/test/WixToolsetTest.Converters/ConditionFixture.cs b/src/test/WixToolsetTest.Converters/ConditionFixture.cs new file mode 100644 index 00000000..bd7f52a8 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/ConditionFixture.cs | |||
@@ -0,0 +1,208 @@ | |||
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 ConditionFixture : BaseConverterFixture | ||
12 | { | ||
13 | [Fact] | ||
14 | public void FixControlCondition() | ||
15 | { | ||
16 | var parse = String.Join(Environment.NewLine, | ||
17 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
18 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
19 | " <Fragment>", | ||
20 | " <UI>", | ||
21 | " <Dialog Id='Dlg1'>", | ||
22 | " <Control Id='Control1'>", | ||
23 | " <Condition Action='hide'>a<>b</Condition>", | ||
24 | " </Control>", | ||
25 | " </Dialog>", | ||
26 | " </UI>", | ||
27 | " </Fragment>", | ||
28 | "</Wix>"); | ||
29 | |||
30 | var expected = new[] | ||
31 | { | ||
32 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
33 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
34 | " <Fragment>", | ||
35 | " <UI>", | ||
36 | " <Dialog Id=\"Dlg1\">", | ||
37 | " <Control Id=\"Control1\" HideCondition=\"a<>b\">", | ||
38 | " ", | ||
39 | " </Control>", | ||
40 | " </Dialog>", | ||
41 | " </UI>", | ||
42 | " </Fragment>", | ||
43 | "</Wix>" | ||
44 | }; | ||
45 | |||
46 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
47 | |||
48 | var messaging = new MockMessaging(); | ||
49 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
50 | |||
51 | var errors = converter.ConvertDocument(document); | ||
52 | Assert.Equal(3, errors); | ||
53 | |||
54 | var actualLines = UnformattedDocumentLines(document); | ||
55 | CompareLineByLine(expected, actualLines); | ||
56 | } | ||
57 | |||
58 | [Fact] | ||
59 | public void FixComponentCondition() | ||
60 | { | ||
61 | var parse = String.Join(Environment.NewLine, | ||
62 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
63 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
64 | " <Fragment>", | ||
65 | " <Component Id='Comp1' Directory='ApplicationFolder'>", | ||
66 | " <Condition>1<2</Condition>", | ||
67 | " </Component>", | ||
68 | " </Fragment>", | ||
69 | "</Wix>"); | ||
70 | |||
71 | var expected = new[] | ||
72 | { | ||
73 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
74 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
75 | " <Fragment>", | ||
76 | " <Component Id=\"Comp1\" Directory=\"ApplicationFolder\" Condition=\"1<2\">", | ||
77 | " ", | ||
78 | " </Component>", | ||
79 | " </Fragment>", | ||
80 | "</Wix>" | ||
81 | }; | ||
82 | |||
83 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
84 | |||
85 | var messaging = new MockMessaging(); | ||
86 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
87 | |||
88 | var errors = converter.ConvertDocument(document); | ||
89 | Assert.Equal(3, errors); | ||
90 | |||
91 | var actualLines = UnformattedDocumentLines(document); | ||
92 | CompareLineByLine(expected, actualLines); | ||
93 | } | ||
94 | |||
95 | [Fact] | ||
96 | public void FixFeatureCondition() | ||
97 | { | ||
98 | var parse = String.Join(Environment.NewLine, | ||
99 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
100 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
101 | " <Fragment>", | ||
102 | " <Feature Id='Feature1'>", | ||
103 | " <Condition Level='0'>PROP = 1</Condition>", | ||
104 | " </Feature>", | ||
105 | " </Fragment>", | ||
106 | "</Wix>"); | ||
107 | |||
108 | var expected = new[] | ||
109 | { | ||
110 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
111 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
112 | " <Fragment>", | ||
113 | " <Feature Id=\"Feature1\">", | ||
114 | " <Level Value=\"0\" Condition=\"PROP = 1\" />", | ||
115 | " </Feature>", | ||
116 | " </Fragment>", | ||
117 | "</Wix>" | ||
118 | }; | ||
119 | |||
120 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
121 | |||
122 | var messaging = new MockMessaging(); | ||
123 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
124 | |||
125 | var errors = converter.ConvertDocument(document); | ||
126 | Assert.Equal(3, errors); | ||
127 | |||
128 | var actualLines = UnformattedDocumentLines(document); | ||
129 | CompareLineByLine(expected, actualLines); | ||
130 | } | ||
131 | |||
132 | [Fact] | ||
133 | public void FixLaunchCondition() | ||
134 | { | ||
135 | var parse = String.Join(Environment.NewLine, | ||
136 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
137 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
138 | " <Fragment>", | ||
139 | " <Condition Message='Stop the install'>", | ||
140 | " 1<2", | ||
141 | " </Condition>", | ||
142 | " </Fragment>", | ||
143 | "</Wix>"); | ||
144 | |||
145 | var expected = new[] | ||
146 | { | ||
147 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
148 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
149 | " <Fragment>", | ||
150 | " <Launch Condition=\"1<2\" Message=\"Stop the install\" />", | ||
151 | " </Fragment>", | ||
152 | "</Wix>" | ||
153 | }; | ||
154 | |||
155 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
156 | |||
157 | var messaging = new MockMessaging(); | ||
158 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
159 | |||
160 | var errors = converter.ConvertDocument(document); | ||
161 | Assert.Equal(3, errors); | ||
162 | |||
163 | var actualLines = UnformattedDocumentLines(document); | ||
164 | CompareLineByLine(expected, actualLines); | ||
165 | } | ||
166 | |||
167 | [Fact] | ||
168 | public void FixPermissionExCondition() | ||
169 | { | ||
170 | var parse = String.Join(Environment.NewLine, | ||
171 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
172 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
173 | " <Fragment>", | ||
174 | " <Component Id='Comp1' Directory='ApplicationFolder'>", | ||
175 | " <PermissionEx Sddl='sddl'>", | ||
176 | " <Condition>1<2</Condition>", | ||
177 | " </PermissionEx>", | ||
178 | " </Component>", | ||
179 | " </Fragment>", | ||
180 | "</Wix>"); | ||
181 | |||
182 | var expected = new[] | ||
183 | { | ||
184 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
185 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
186 | " <Fragment>", | ||
187 | " <Component Id=\"Comp1\" Directory=\"ApplicationFolder\">", | ||
188 | " <PermissionEx Sddl=\"sddl\" Condition=\"1<2\">", | ||
189 | " ", | ||
190 | " </PermissionEx>", | ||
191 | " </Component>", | ||
192 | " </Fragment>", | ||
193 | "</Wix>" | ||
194 | }; | ||
195 | |||
196 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
197 | |||
198 | var messaging = new MockMessaging(); | ||
199 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
200 | |||
201 | var errors = converter.ConvertDocument(document); | ||
202 | Assert.Equal(3, errors); | ||
203 | |||
204 | var actualLines = UnformattedDocumentLines(document); | ||
205 | CompareLineByLine(expected, actualLines); | ||
206 | } | ||
207 | } | ||
208 | } | ||
diff --git a/src/test/WixToolsetTest.Converters/ConverterFixture.cs b/src/test/WixToolsetTest.Converters/ConverterFixture.cs index 7a39b0c6..3378b804 100644 --- a/src/test/WixToolsetTest.Converters/ConverterFixture.cs +++ b/src/test/WixToolsetTest.Converters/ConverterFixture.cs | |||
@@ -169,95 +169,6 @@ namespace WixToolsetTest.Converters | |||
169 | } | 169 | } |
170 | 170 | ||
171 | [Fact] | 171 | [Fact] |
172 | public void CanFixCdataWhitespace() | ||
173 | { | ||
174 | var parse = String.Join(Environment.NewLine, | ||
175 | "<?xml version='1.0' encoding='utf-8'?>", | ||
176 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
177 | " <Fragment>", | ||
178 | " <Property Id='Prop'>", | ||
179 | " <![CDATA[1<2]]>", | ||
180 | " </Property>", | ||
181 | " </Fragment>", | ||
182 | "</Wix>"); | ||
183 | |||
184 | var expected = String.Join(Environment.NewLine, | ||
185 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
186 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
187 | " <Fragment>", | ||
188 | " <Property Id=\"Prop\"><![CDATA[1<2]]></Property>", | ||
189 | " </Fragment>", | ||
190 | "</Wix>"); | ||
191 | |||
192 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
193 | |||
194 | var messaging = new MockMessaging(); | ||
195 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
196 | |||
197 | var errors = converter.ConvertDocument(document); | ||
198 | |||
199 | var actual = UnformattedDocumentString(document); | ||
200 | |||
201 | Assert.Equal(expected, actual); | ||
202 | Assert.Equal(2, errors); | ||
203 | } | ||
204 | |||
205 | [Fact] | ||
206 | public void CanFixCdataWithWhitespace() | ||
207 | { | ||
208 | var parse = String.Join(Environment.NewLine, | ||
209 | "<?xml version='1.0' encoding='utf-8'?>", | ||
210 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
211 | " <Fragment>", | ||
212 | " <Property Id='Prop'>", | ||
213 | " <![CDATA[", | ||
214 | " 1<2", | ||
215 | " ]]>", | ||
216 | " </Property>", | ||
217 | " </Fragment>", | ||
218 | "</Wix>"); | ||
219 | |||
220 | var expected = String.Join(Environment.NewLine, | ||
221 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
222 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
223 | " <Fragment>", | ||
224 | " <Property Id=\"Prop\"><![CDATA[1<2]]></Property>", | ||
225 | " </Fragment>", | ||
226 | "</Wix>"); | ||
227 | |||
228 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
229 | |||
230 | var messaging = new MockMessaging(); | ||
231 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
232 | |||
233 | var errors = converter.ConvertDocument(document); | ||
234 | |||
235 | var actual = UnformattedDocumentString(document); | ||
236 | |||
237 | Assert.Equal(expected, actual); | ||
238 | Assert.Equal(2, errors); | ||
239 | } | ||
240 | |||
241 | [Fact] | ||
242 | public void CanKeepCdataWithOnlyWhitespace() | ||
243 | { | ||
244 | var parse = String.Join(Environment.NewLine, | ||
245 | "<?xml version='1.0' encoding='utf-8'?>", | ||
246 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
247 | " <Fragment>", | ||
248 | " <Property Id='Prop'><![CDATA[ ]]></Property>", | ||
249 | " </Fragment>", | ||
250 | "</Wix>"); | ||
251 | |||
252 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
253 | |||
254 | var messaging = new MockMessaging(); | ||
255 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
256 | var errors = converter.ConvertDocument(document); | ||
257 | Assert.Equal(0, errors); | ||
258 | } | ||
259 | |||
260 | [Fact] | ||
261 | public void CanConvertMainNamespace() | 172 | public void CanConvertMainNamespace() |
262 | { | 173 | { |
263 | var parse = String.Join(Environment.NewLine, | 174 | var parse = String.Join(Environment.NewLine, |
@@ -475,34 +386,6 @@ namespace WixToolsetTest.Converters | |||
475 | } | 386 | } |
476 | 387 | ||
477 | [Fact] | 388 | [Fact] |
478 | public void CanConvertCustomTableBootstrapperApplicationData() | ||
479 | { | ||
480 | var parse = String.Join(Environment.NewLine, | ||
481 | "<?xml version='1.0' encoding='utf-8'?>", | ||
482 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
483 | " <CustomTable Id='FgAppx' BootstrapperApplicationData='yes' />", | ||
484 | "</Wix>"); | ||
485 | |||
486 | var expected = String.Join(Environment.NewLine, | ||
487 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
488 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
489 | " <CustomTable Id=\"FgAppx\" Unreal=\"yes\" />", | ||
490 | "</Wix>"); | ||
491 | |||
492 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
493 | |||
494 | var messaging = new MockMessaging(); | ||
495 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
496 | |||
497 | var errors = converter.ConvertDocument(document); | ||
498 | |||
499 | var actual = UnformattedDocumentString(document); | ||
500 | |||
501 | Assert.Equal(1, errors); | ||
502 | Assert.Equal(expected, actual); | ||
503 | } | ||
504 | |||
505 | [Fact] | ||
506 | public void CanConvertShortNameDirectoryWithoutName() | 389 | public void CanConvertShortNameDirectoryWithoutName() |
507 | { | 390 | { |
508 | var parse = String.Join(Environment.NewLine, | 391 | var parse = String.Join(Environment.NewLine, |
@@ -585,39 +468,5 @@ namespace WixToolsetTest.Converters | |||
585 | Assert.Equal(1, errors); | 468 | Assert.Equal(1, errors); |
586 | Assert.Equal(expected, actual); | 469 | Assert.Equal(expected, actual); |
587 | } | 470 | } |
588 | |||
589 | [Fact] | ||
590 | public void CanConvertCustomAction() | ||
591 | { | ||
592 | var parse = String.Join(Environment.NewLine, | ||
593 | "<?xml version='1.0' encoding='utf-8'?>", | ||
594 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
595 | " <CustomAction Id='Foo' BinaryKey='WixCA' DllEntry='CAQuietExec' />", | ||
596 | " <CustomAction Id='Foo' BinaryKey='WixCA_x64' DllEntry='CAQuietExec64' />", | ||
597 | " <CustomAction Id='Foo' BinaryKey='UtilCA' DllEntry='WixQuietExec' />", | ||
598 | " <CustomAction Id='Foo' BinaryKey='UtilCA_x64' DllEntry='WixQuietExec64' />", | ||
599 | "</Wix>"); | ||
600 | |||
601 | var expected = String.Join(Environment.NewLine, | ||
602 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
603 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
604 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X86\" DllEntry=\"WixQuietExec\" />", | ||
605 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X64\" DllEntry=\"WixQuietExec64\" />", | ||
606 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X86\" DllEntry=\"WixQuietExec\" />", | ||
607 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X64\" DllEntry=\"WixQuietExec64\" />", | ||
608 | "</Wix>"); | ||
609 | |||
610 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
611 | |||
612 | var messaging = new MockMessaging(); | ||
613 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
614 | |||
615 | var errors = converter.ConvertDocument(document); | ||
616 | |||
617 | var actual = UnformattedDocumentString(document); | ||
618 | |||
619 | Assert.Equal(6, errors); | ||
620 | Assert.Equal(expected, actual); | ||
621 | } | ||
622 | } | 471 | } |
623 | } | 472 | } |
diff --git a/src/test/WixToolsetTest.Converters/CustomActionFixture.cs b/src/test/WixToolsetTest.Converters/CustomActionFixture.cs new file mode 100644 index 00000000..1eab0926 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/CustomActionFixture.cs | |||
@@ -0,0 +1,90 @@ | |||
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.IO; | ||
7 | using System.Xml.Linq; | ||
8 | using WixToolset.Converters; | ||
9 | using WixToolsetTest.Converters.Mocks; | ||
10 | using Xunit; | ||
11 | |||
12 | public class CustomActionFixture : BaseConverterFixture | ||
13 | { | ||
14 | [Fact] | ||
15 | public void CanConvertCustomAction() | ||
16 | { | ||
17 | var parse = String.Join(Environment.NewLine, | ||
18 | "<?xml version='1.0' encoding='utf-8'?>", | ||
19 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
20 | " <CustomAction Id='Foo' BinaryKey='WixCA' DllEntry='CAQuietExec' />", | ||
21 | " <CustomAction Id='Foo' BinaryKey='WixCA_x64' DllEntry='CAQuietExec64' />", | ||
22 | " <CustomAction Id='Foo' BinaryKey='UtilCA' DllEntry='WixQuietExec' />", | ||
23 | " <CustomAction Id='Foo' BinaryKey='UtilCA_x64' DllEntry='WixQuietExec64' />", | ||
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 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X86\" DllEntry=\"WixQuietExec\" />", | ||
30 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X64\" DllEntry=\"WixQuietExec64\" />", | ||
31 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X86\" DllEntry=\"WixQuietExec\" />", | ||
32 | " <CustomAction Id=\"Foo\" BinaryKey=\"Wix4UtilCA_X64\" DllEntry=\"WixQuietExec64\" />", | ||
33 | "</Wix>"); | ||
34 | |||
35 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
36 | |||
37 | var messaging = new MockMessaging(); | ||
38 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
39 | |||
40 | var errors = converter.ConvertDocument(document); | ||
41 | |||
42 | var actual = UnformattedDocumentString(document); | ||
43 | |||
44 | Assert.Equal(6, errors); | ||
45 | Assert.Equal(expected, actual); | ||
46 | } | ||
47 | |||
48 | [Fact] | ||
49 | public void CanConvertCustomActionScript() | ||
50 | { | ||
51 | var parse = String.Join(Environment.NewLine, | ||
52 | "<?xml version='1.0' encoding='utf-8'?>", | ||
53 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
54 | " <CustomAction Id='Foo' Script='jscript'>", | ||
55 | " function() {", | ||
56 | " var x = 0;", | ||
57 | " return x;", | ||
58 | " }", | ||
59 | " </CustomAction>", | ||
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 | " <CustomAction Id=\"Foo\" Script=\"jscript\" ScriptFile=\"Foo.js\" />", | ||
66 | "</Wix>"); | ||
67 | |||
68 | var expectedScript = String.Join("\n", | ||
69 | "function() {", | ||
70 | " var x = 0;", | ||
71 | " return x;", | ||
72 | " }"); | ||
73 | |||
74 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
75 | |||
76 | var messaging = new MockMessaging(); | ||
77 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
78 | |||
79 | var errors = converter.ConvertDocument(document); | ||
80 | |||
81 | var actual = UnformattedDocumentString(document); | ||
82 | |||
83 | Assert.Equal(1, errors); | ||
84 | Assert.Equal(expected, actual); | ||
85 | |||
86 | var script = File.ReadAllText("Foo.js"); | ||
87 | Assert.Equal(expectedScript, script); | ||
88 | } | ||
89 | } | ||
90 | } | ||
diff --git a/src/test/WixToolsetTest.Converters/CustomTableFixture.cs b/src/test/WixToolsetTest.Converters/CustomTableFixture.cs index 5a572294..c09534ee 100644 --- a/src/test/WixToolsetTest.Converters/CustomTableFixture.cs +++ b/src/test/WixToolsetTest.Converters/CustomTableFixture.cs | |||
@@ -46,5 +46,150 @@ namespace WixToolsetTest.Converters | |||
46 | var actualLines = UnformattedDocumentLines(document); | 46 | var actualLines = UnformattedDocumentLines(document); |
47 | CompareLineByLine(expected, actualLines); | 47 | CompareLineByLine(expected, actualLines); |
48 | } | 48 | } |
49 | |||
50 | [Fact] | ||
51 | public void FixCustomRowTextValue() | ||
52 | { | ||
53 | var parse = String.Join(Environment.NewLine, | ||
54 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
55 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
56 | " <Fragment>", | ||
57 | " <CustomTable Id='Custom1'>", | ||
58 | " <Row Id='Column1'>", | ||
59 | " Some value", | ||
60 | " </Row>", | ||
61 | " </CustomTable>", | ||
62 | " </Fragment>", | ||
63 | "</Wix>"); | ||
64 | |||
65 | var expected = new[] | ||
66 | { | ||
67 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
68 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
69 | " <Fragment>", | ||
70 | " <CustomTable Id=\"Custom1\">", | ||
71 | " <Row Id=\"Column1\" Value=\"Some value\" />", | ||
72 | " </CustomTable>", | ||
73 | " </Fragment>", | ||
74 | "</Wix>" | ||
75 | }; | ||
76 | |||
77 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
78 | |||
79 | var messaging = new MockMessaging(); | ||
80 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
81 | |||
82 | var errors = converter.ConvertDocument(document); | ||
83 | Assert.Equal(3, errors); | ||
84 | |||
85 | var actualLines = UnformattedDocumentLines(document); | ||
86 | CompareLineByLine(expected, actualLines); | ||
87 | } | ||
88 | |||
89 | [Fact] | ||
90 | public void FixCustomRowCdataValue() | ||
91 | { | ||
92 | var parse = String.Join(Environment.NewLine, | ||
93 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
94 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
95 | " <Fragment>", | ||
96 | " <CustomTable Id='Custom1'>", | ||
97 | " <Row Id='Column1'>", | ||
98 | " <![CDATA[", | ||
99 | " Some value", | ||
100 | " ]]>", | ||
101 | " </Row>", | ||
102 | " </CustomTable>", | ||
103 | " </Fragment>", | ||
104 | "</Wix>"); | ||
105 | |||
106 | var expected = new[] | ||
107 | { | ||
108 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
109 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
110 | " <Fragment>", | ||
111 | " <CustomTable Id=\"Custom1\">", | ||
112 | " <Row Id=\"Column1\" Value=\"Some value\" />", | ||
113 | " </CustomTable>", | ||
114 | " </Fragment>", | ||
115 | "</Wix>" | ||
116 | }; | ||
117 | |||
118 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
119 | |||
120 | var messaging = new MockMessaging(); | ||
121 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
122 | |||
123 | var errors = converter.ConvertDocument(document); | ||
124 | Assert.Equal(3, errors); | ||
125 | |||
126 | var actualLines = UnformattedDocumentLines(document); | ||
127 | CompareLineByLine(expected, actualLines); | ||
128 | } | ||
129 | |||
130 | [Fact] | ||
131 | public void FixCustomRowWithoutValue() | ||
132 | { | ||
133 | var parse = String.Join(Environment.NewLine, | ||
134 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
135 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
136 | " <Fragment>", | ||
137 | " <CustomTable Id='Custom1'>", | ||
138 | " <Row Id='Column1'></Row>", | ||
139 | " </CustomTable>", | ||
140 | " </Fragment>", | ||
141 | "</Wix>"); | ||
142 | |||
143 | var expected = new[] | ||
144 | { | ||
145 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
146 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
147 | " <Fragment>", | ||
148 | " <CustomTable Id=\"Custom1\">", | ||
149 | " <Row Id=\"Column1\"></Row>", | ||
150 | " </CustomTable>", | ||
151 | " </Fragment>", | ||
152 | "</Wix>" | ||
153 | }; | ||
154 | |||
155 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
156 | |||
157 | var messaging = new MockMessaging(); | ||
158 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
159 | |||
160 | var errors = converter.ConvertDocument(document); | ||
161 | Assert.Equal(2, errors); | ||
162 | |||
163 | var actualLines = UnformattedDocumentLines(document); | ||
164 | CompareLineByLine(expected, actualLines); | ||
165 | } | ||
166 | |||
167 | [Fact] | ||
168 | public void CanConvertCustomTableBootstrapperApplicationData() | ||
169 | { | ||
170 | var parse = String.Join(Environment.NewLine, | ||
171 | "<?xml version='1.0' encoding='utf-8'?>", | ||
172 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
173 | " <CustomTable Id='FgAppx' BootstrapperApplicationData='yes' />", | ||
174 | "</Wix>"); | ||
175 | |||
176 | var expected = String.Join(Environment.NewLine, | ||
177 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
178 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
179 | " <CustomTable Id=\"FgAppx\" Unreal=\"yes\" />", | ||
180 | "</Wix>"); | ||
181 | |||
182 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
183 | |||
184 | var messaging = new MockMessaging(); | ||
185 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
186 | |||
187 | var errors = converter.ConvertDocument(document); | ||
188 | |||
189 | var actual = UnformattedDocumentString(document); | ||
190 | |||
191 | Assert.Equal(1, errors); | ||
192 | Assert.Equal(expected, actual); | ||
193 | } | ||
49 | } | 194 | } |
50 | } | 195 | } |
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 | } | ||
diff --git a/src/test/WixToolsetTest.Converters/SequenceFixture.cs b/src/test/WixToolsetTest.Converters/SequenceFixture.cs new file mode 100644 index 00000000..997dcd6a --- /dev/null +++ b/src/test/WixToolsetTest.Converters/SequenceFixture.cs | |||
@@ -0,0 +1,50 @@ | |||
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 SequenceFixture : BaseConverterFixture | ||
12 | { | ||
13 | [Fact] | ||
14 | public void FixCondition() | ||
15 | { | ||
16 | var parse = String.Join(Environment.NewLine, | ||
17 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
18 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
19 | " <Fragment>", | ||
20 | " <InstallUISequence>", | ||
21 | " <Custom Action='ExampleCA' After='InstallFiles'>NOT Installed</Custom>", | ||
22 | " </InstallUISequence>", | ||
23 | " </Fragment>", | ||
24 | "</Wix>"); | ||
25 | |||
26 | var expected = new[] | ||
27 | { | ||
28 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
29 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
30 | " <Fragment>", | ||
31 | " <InstallUISequence>", | ||
32 | " <Custom Action=\"ExampleCA\" After=\"InstallFiles\" Condition=\"NOT Installed\" />", | ||
33 | " </InstallUISequence>", | ||
34 | " </Fragment>", | ||
35 | "</Wix>" | ||
36 | }; | ||
37 | |||
38 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
39 | |||
40 | var messaging = new MockMessaging(); | ||
41 | var converter = new Wix3Converter(messaging, 2, null, null); | ||
42 | |||
43 | var errors = converter.ConvertDocument(document); | ||
44 | Assert.Equal(3, errors); | ||
45 | |||
46 | var actualLines = UnformattedDocumentLines(document); | ||
47 | CompareLineByLine(expected, actualLines); | ||
48 | } | ||
49 | } | ||
50 | } | ||