aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/WixToolsetTest.Converters/BitnessFixture.cs181
1 files changed, 181 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.Converters/BitnessFixture.cs b/src/test/WixToolsetTest.Converters/BitnessFixture.cs
new file mode 100644
index 00000000..9996806d
--- /dev/null
+++ b/src/test/WixToolsetTest.Converters/BitnessFixture.cs
@@ -0,0 +1,181 @@
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
3namespace WixToolsetTest.Converters
4{
5 using System;
6 using System.Xml.Linq;
7 using WixBuildTools.TestSupport;
8 using WixToolset.Converters;
9 using WixToolsetTest.Converters.Mocks;
10 using Xunit;
11
12 public class BitnessFixture : BaseConverterFixture
13 {
14 [Fact]
15 public void FixComponentBitness()
16 {
17 var parse = String.Join(Environment.NewLine,
18 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
19 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
20 " <Fragment>",
21 " <Component>",
22 " <File Source='default.exe' />",
23 " </Component>",
24 " <Component Win64='no'>",
25 " <File Source='32bit.exe' />",
26 " </Component>",
27 " <Component Win64='yes'>",
28 " <File Source='64bit.exe' />",
29 " </Component>",
30 " </Fragment>",
31 "</Wix>");
32
33 var expected = new[]
34 {
35 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
36 " <Fragment>",
37 " <Component>",
38 " <File Id=\"default.exe\" Source=\"default.exe\" />",
39 " </Component>",
40 " <Component Bitness=\"always32\">",
41 " <File Id=\"_32bit.exe\" Source=\"32bit.exe\" />",
42 " </Component>",
43 " <Component Bitness=\"always64\">",
44 " <File Id=\"_64bit.exe\" Source=\"64bit.exe\" />",
45 " </Component>",
46 " </Fragment>",
47 "</Wix>"
48 };
49
50 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
51
52 var messaging = new MockMessaging();
53 var converter = new WixConverter(messaging, 2, null, null);
54
55 var errors = converter.ConvertDocument(document);
56 Assert.Equal(7, errors);
57
58 var actualLines = UnformattedDocumentLines(document);
59 WixAssert.CompareLineByLine(expected, actualLines);
60 }
61
62 [Fact]
63 public void FixRegistrySearchBitness()
64 {
65 var parse = String.Join(Environment.NewLine,
66 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
67 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
68 " <Fragment>",
69 " <Property Id='BITNESSDEFAULT'>",
70 " <RegistrySearch Id='SampleRegSearch' Root='HKLM' Key='SampleReg' Type='raw'></RegistrySearch>",
71 " </Property>",
72 " <Property Id='BITNESS32'>",
73 " <RegistrySearch Id='SampleRegSearch' Root='HKLM' Key='SampleReg' Type='raw' Win64='no'></RegistrySearch>",
74 " </Property>",
75 " <Property Id='BITNESS64'>",
76 " <RegistrySearch Id='SampleRegSearch' Root='HKLM' Key='SampleReg' Type='raw' Win64='yes'></RegistrySearch>",
77 " </Property>",
78 " </Fragment>",
79 "</Wix>");
80
81 var expected = new[]
82 {
83 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
84 " <Fragment>",
85 " <Property Id=\"BITNESSDEFAULT\">",
86 " <RegistrySearch Id=\"SampleRegSearch\" Root=\"HKLM\" Key=\"SampleReg\" Type=\"raw\"></RegistrySearch>",
87 " </Property>",
88 " <Property Id=\"BITNESS32\">",
89 " <RegistrySearch Id=\"SampleRegSearch\" Root=\"HKLM\" Key=\"SampleReg\" Type=\"raw\" Bitness=\"always32\"></RegistrySearch>",
90 " </Property>",
91 " <Property Id=\"BITNESS64\">",
92 " <RegistrySearch Id=\"SampleRegSearch\" Root=\"HKLM\" Key=\"SampleReg\" Type=\"raw\" Bitness=\"always64\"></RegistrySearch>",
93 " </Property>",
94 " </Fragment>",
95 "</Wix>"
96 };
97
98 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
99
100 var messaging = new MockMessaging();
101 var converter = new WixConverter(messaging, 2, null, null);
102
103 var errors = converter.ConvertDocument(document);
104 Assert.Equal(4, errors);
105
106 var actualLines = UnformattedDocumentLines(document);
107 WixAssert.CompareLineByLine(expected, actualLines);
108 }
109
110 [Fact]
111 public void FixUtilRegistrySearchBitness()
112 {
113 var parse = String.Join(Environment.NewLine,
114 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>",
115 " <Fragment>",
116 " <util:RegistrySearch Id='RegValue' Root='HKLM' Key='Converter' Variable='Test' />",
117 " <util:RegistrySearch Id='RegValue2' Root='HKLM' Key='Converter' Variable='Test' Result='value' Win64='no' />",
118 " <util:RegistrySearch Id='RegValue3' Root='HKLM' Key='Converter' Variable='Test' Result='exists' Win64='yes' />",
119 " </Fragment>",
120 "</Wix>");
121
122 var expected = new[]
123 {
124 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">",
125 " <Fragment>",
126 " <util:RegistrySearch Id=\"RegValue\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" />",
127 " <util:RegistrySearch Id=\"RegValue2\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" Result=\"value\" Bitness=\"always32\" />",
128 " <util:RegistrySearch Id=\"RegValue3\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" Result=\"exists\" Bitness=\"always64\" />",
129 " </Fragment>",
130 "</Wix>"
131 };
132
133 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
134
135 var messaging = new MockMessaging();
136 var converter = new WixConverter(messaging, 2, null, null);
137
138 var errors = converter.ConvertDocument(document);
139 Assert.Equal(6, errors);
140
141 var actualLines = UnformattedDocumentLines(document);
142 WixAssert.CompareLineByLine(expected, actualLines);
143 }
144
145 [Fact]
146 public void FixApprovedExeBitness()
147 {
148 var parse = String.Join(Environment.NewLine,
149 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
150 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
151 " <Bundle>",
152 " <ApprovedExeForElevation Id='Default' Key='WixToolset\\BurnTesting' Value='Test' />",
153 " <ApprovedExeForElevation Id='Bitness32' Key='WixToolset\\BurnTesting' Value='Test' Win64='no' />",
154 " <ApprovedExeForElevation Id='Bitness64' Key='WixToolset\\BurnTesting' Value='Test' Win64='yes' />",
155 " </Bundle>",
156 "</Wix>");
157
158 var expected = new[]
159 {
160 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
161 " <Bundle>",
162 " <ApprovedExeForElevation Id=\"Default\" Key=\"WixToolset\\BurnTesting\" Value=\"Test\" />",
163 " <ApprovedExeForElevation Id=\"Bitness32\" Key=\"WixToolset\\BurnTesting\" Value=\"Test\" Bitness=\"always32\" />",
164 " <ApprovedExeForElevation Id=\"Bitness64\" Key=\"WixToolset\\BurnTesting\" Value=\"Test\" Bitness=\"always64\" />",
165 " </Bundle>",
166 "</Wix>"
167 };
168
169 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
170
171 var messaging = new MockMessaging();
172 var converter = new WixConverter(messaging, 2, null, null);
173
174 var errors = converter.ConvertDocument(document);
175 Assert.Equal(4, errors);
176
177 var actualLines = UnformattedDocumentLines(document);
178 WixAssert.CompareLineByLine(expected, actualLines);
179 }
180 }
181}