diff options
Diffstat (limited to 'src/test/WixToolsetTest.Converters/CustomTableFixture.cs')
| -rw-r--r-- | src/test/WixToolsetTest.Converters/CustomTableFixture.cs | 363 |
1 files changed, 0 insertions, 363 deletions
diff --git a/src/test/WixToolsetTest.Converters/CustomTableFixture.cs b/src/test/WixToolsetTest.Converters/CustomTableFixture.cs deleted file mode 100644 index 2b81a863..00000000 --- a/src/test/WixToolsetTest.Converters/CustomTableFixture.cs +++ /dev/null | |||
| @@ -1,363 +0,0 @@ | |||
| 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 WixBuildTools.TestSupport; | ||
| 8 | using WixToolset.Converters; | ||
| 9 | using WixToolsetTest.Converters.Mocks; | ||
| 10 | using Xunit; | ||
| 11 | |||
| 12 | public class CustomTableFixture : BaseConverterFixture | ||
| 13 | { | ||
| 14 | [Fact] | ||
| 15 | public void FixCustomTableCategoryAndModularization() | ||
| 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 | " <CustomTable Id='Custom1'>", | ||
| 22 | " <Column Id='Column1' Type='string' Category='Text' Modularize='Column' />", | ||
| 23 | " </CustomTable>", | ||
| 24 | " </Fragment>", | ||
| 25 | "</Wix>"); | ||
| 26 | |||
| 27 | var expected = new[] | ||
| 28 | { | ||
| 29 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 30 | " <Fragment>", | ||
| 31 | " <CustomTable Id=\"Custom1\">", | ||
| 32 | " <Column Id=\"Column1\" Type=\"string\" Category=\"text\" Modularize=\"column\" />", | ||
| 33 | " </CustomTable>", | ||
| 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 WixConverter(messaging, 2, null, null); | ||
| 42 | |||
| 43 | var errors = converter.ConvertDocument(document); | ||
| 44 | Assert.Equal(4, errors); | ||
| 45 | |||
| 46 | var actualLines = UnformattedDocumentLines(document); | ||
| 47 | WixAssert.CompareLineByLine(expected, actualLines); | ||
| 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>", | ||
| 59 | " <Data Id='Column1'>", | ||
| 60 | " Some value", | ||
| 61 | " </Data>", | ||
| 62 | " </Row>", | ||
| 63 | " </CustomTable>", | ||
| 64 | " </Fragment>", | ||
| 65 | "</Wix>"); | ||
| 66 | |||
| 67 | var expected = new[] | ||
| 68 | { | ||
| 69 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 70 | " <Fragment>", | ||
| 71 | " <CustomTable Id=\"Custom1\">", | ||
| 72 | " <Row>", | ||
| 73 | " <Data Id=\"Column1\" Value=\"Some value\" />", | ||
| 74 | " </Row>", | ||
| 75 | " </CustomTable>", | ||
| 76 | " </Fragment>", | ||
| 77 | "</Wix>" | ||
| 78 | }; | ||
| 79 | |||
| 80 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 81 | |||
| 82 | var messaging = new MockMessaging(); | ||
| 83 | var converter = new WixConverter(messaging, 2, null, null); | ||
| 84 | |||
| 85 | var errors = converter.ConvertDocument(document); | ||
| 86 | Assert.Equal(4, errors); | ||
| 87 | |||
| 88 | var actualLines = UnformattedDocumentLines(document); | ||
| 89 | WixAssert.CompareLineByLine(expected, actualLines); | ||
| 90 | } | ||
| 91 | |||
| 92 | [Fact] | ||
| 93 | public void FixCustomRowCdataValue() | ||
| 94 | { | ||
| 95 | var parse = String.Join(Environment.NewLine, | ||
| 96 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
| 97 | " <Fragment>", | ||
| 98 | " <CustomTable Id='Custom1'>", | ||
| 99 | " <Row>", | ||
| 100 | " <Data Id='Column1'>", | ||
| 101 | " <![CDATA[", | ||
| 102 | " Some value", | ||
| 103 | " ]]>", | ||
| 104 | " </Data>", | ||
| 105 | " </Row>", | ||
| 106 | " </CustomTable>", | ||
| 107 | " </Fragment>", | ||
| 108 | "</Wix>"); | ||
| 109 | |||
| 110 | var expected = new[] | ||
| 111 | { | ||
| 112 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 113 | " <Fragment>", | ||
| 114 | " <CustomTable Id=\"Custom1\">", | ||
| 115 | " <Row>", | ||
| 116 | " <Data Id=\"Column1\" Value=\"Some value\" />", | ||
| 117 | " </Row>", | ||
| 118 | " </CustomTable>", | ||
| 119 | " </Fragment>", | ||
| 120 | "</Wix>" | ||
| 121 | }; | ||
| 122 | |||
| 123 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 124 | |||
| 125 | var messaging = new MockMessaging(); | ||
| 126 | var converter = new WixConverter(messaging, 2, null, null); | ||
| 127 | |||
| 128 | var errors = converter.ConvertDocument(document); | ||
| 129 | Assert.Equal(3, errors); | ||
| 130 | |||
| 131 | var actualLines = UnformattedDocumentLines(document); | ||
| 132 | WixAssert.CompareLineByLine(expected, actualLines); | ||
| 133 | } | ||
| 134 | |||
| 135 | [Fact] | ||
| 136 | public void FixCustomRowWithoutValue() | ||
| 137 | { | ||
| 138 | var parse = String.Join(Environment.NewLine, | ||
| 139 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
| 140 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
| 141 | " <Fragment>", | ||
| 142 | " <CustomTable Id='Custom1'>", | ||
| 143 | " <Row Id='Column1'></Row>", | ||
| 144 | " </CustomTable>", | ||
| 145 | " </Fragment>", | ||
| 146 | "</Wix>"); | ||
| 147 | |||
| 148 | var expected = new[] | ||
| 149 | { | ||
| 150 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 151 | " <Fragment>", | ||
| 152 | " <CustomTable Id=\"Custom1\">", | ||
| 153 | " <Row Id=\"Column1\"></Row>", | ||
| 154 | " </CustomTable>", | ||
| 155 | " </Fragment>", | ||
| 156 | "</Wix>" | ||
| 157 | }; | ||
| 158 | |||
| 159 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 160 | |||
| 161 | var messaging = new MockMessaging(); | ||
| 162 | var converter = new WixConverter(messaging, 2, null, null); | ||
| 163 | |||
| 164 | var errors = converter.ConvertDocument(document); | ||
| 165 | Assert.Equal(3, errors); | ||
| 166 | |||
| 167 | var actualLines = UnformattedDocumentLines(document); | ||
| 168 | WixAssert.CompareLineByLine(expected, actualLines); | ||
| 169 | } | ||
| 170 | |||
| 171 | [Fact] | ||
| 172 | public void CanConvertBundleCustomTableBootstrapperApplicationData() | ||
| 173 | { | ||
| 174 | var parse = String.Join(Environment.NewLine, | ||
| 175 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 176 | " <CustomTable Id='FgAppx' BootstrapperApplicationData='yes'>", | ||
| 177 | " <Column Id='Column1' PrimaryKey='yes' Type='string' Width='0' Category='text' Description='The first custom column.' />", | ||
| 178 | " <Row>", | ||
| 179 | " <Data Column='Column1'>Row1</Data>", | ||
| 180 | " </Row>", | ||
| 181 | " </CustomTable>", | ||
| 182 | "</Wix>"); | ||
| 183 | |||
| 184 | var expected = String.Join(Environment.NewLine, | ||
| 185 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 186 | " <BundleCustomData Id=\"FgAppx\">", | ||
| 187 | " <BundleAttributeDefinition Id=\"Column1\" />", | ||
| 188 | " <BundleElement>", | ||
| 189 | " <BundleAttribute Id=\"Column1\" Value=\"Row1\" />", | ||
| 190 | " </BundleElement>", | ||
| 191 | " </BundleCustomData>", | ||
| 192 | "</Wix>"); | ||
| 193 | |||
| 194 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 195 | |||
| 196 | var messaging = new MockMessaging(); | ||
| 197 | var converter = new WixConverter(messaging, 2, customTableTarget: CustomTableTarget.Bundle); | ||
| 198 | |||
| 199 | var errors = converter.ConvertDocument(document); | ||
| 200 | |||
| 201 | var actual = UnformattedDocumentString(document); | ||
| 202 | |||
| 203 | Assert.Equal(2, errors); | ||
| 204 | Assert.Equal(expected, actual); | ||
| 205 | } | ||
| 206 | |||
| 207 | [Fact] | ||
| 208 | public void CanConvertBundleCustomTableRef() | ||
| 209 | { | ||
| 210 | var parse = String.Join(Environment.NewLine, | ||
| 211 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 212 | " <CustomTable Id='FgAppx'>", | ||
| 213 | " <Row>", | ||
| 214 | " <Data Column='Column1'>Row1</Data>", | ||
| 215 | " </Row>", | ||
| 216 | " </CustomTable>", | ||
| 217 | "</Wix>"); | ||
| 218 | |||
| 219 | var expected = String.Join(Environment.NewLine, | ||
| 220 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 221 | " <BundleCustomDataRef Id=\"FgAppx\">", | ||
| 222 | " <BundleElement>", | ||
| 223 | " <BundleAttribute Id=\"Column1\" Value=\"Row1\" />", | ||
| 224 | " </BundleElement>", | ||
| 225 | " </BundleCustomDataRef>", | ||
| 226 | "</Wix>"); | ||
| 227 | |||
| 228 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 229 | |||
| 230 | var messaging = new MockMessaging(); | ||
| 231 | var converter = new WixConverter(messaging, 2, customTableTarget: CustomTableTarget.Bundle); | ||
| 232 | |||
| 233 | var errors = converter.ConvertDocument(document); | ||
| 234 | |||
| 235 | var actual = UnformattedDocumentString(document); | ||
| 236 | |||
| 237 | Assert.Equal(2, errors); | ||
| 238 | Assert.Equal(expected, actual); | ||
| 239 | } | ||
| 240 | |||
| 241 | [Fact] | ||
| 242 | public void CanConvertMsiCustomTableBootstrapperApplicationData() | ||
| 243 | { | ||
| 244 | var parse = String.Join(Environment.NewLine, | ||
| 245 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 246 | " <CustomTable Id='FgAppx' BootstrapperApplicationData='yes'>", | ||
| 247 | " <Column Id='Column1' PrimaryKey='yes' Type='string' Width='0' Category='text' Description='The first custom column.' />", | ||
| 248 | " <Row>", | ||
| 249 | " <Data Column='Column1'>Row1</Data>", | ||
| 250 | " </Row>", | ||
| 251 | " </CustomTable>", | ||
| 252 | "</Wix>"); | ||
| 253 | |||
| 254 | var expected = String.Join(Environment.NewLine, | ||
| 255 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 256 | " <CustomTable Id=\"FgAppx\" Unreal=\"yes\">", | ||
| 257 | " <Column Id=\"Column1\" PrimaryKey=\"yes\" Type=\"string\" Width=\"0\" Category=\"text\" Description=\"The first custom column.\" />", | ||
| 258 | " <Row>", | ||
| 259 | " <Data Column=\"Column1\" Value=\"Row1\" />", | ||
| 260 | " </Row>", | ||
| 261 | " </CustomTable>", | ||
| 262 | "</Wix>"); | ||
| 263 | |||
| 264 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 265 | |||
| 266 | var messaging = new MockMessaging(); | ||
| 267 | var converter = new WixConverter(messaging, 2, customTableTarget: CustomTableTarget.Msi); | ||
| 268 | |||
| 269 | var errors = converter.ConvertDocument(document); | ||
| 270 | |||
| 271 | var actual = UnformattedDocumentString(document); | ||
| 272 | |||
| 273 | Assert.Equal(2, errors); | ||
| 274 | Assert.Equal(expected, actual); | ||
| 275 | } | ||
| 276 | |||
| 277 | [Fact] | ||
| 278 | public void CanConvertMsiCustomTableRef() | ||
| 279 | { | ||
| 280 | var parse = String.Join(Environment.NewLine, | ||
| 281 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 282 | " <CustomTable Id='FgAppx'>", | ||
| 283 | " <Row>", | ||
| 284 | " <Data Column='Column1'>Row1</Data>", | ||
| 285 | " </Row>", | ||
| 286 | " </CustomTable>", | ||
| 287 | "</Wix>"); | ||
| 288 | |||
| 289 | var expected = String.Join(Environment.NewLine, | ||
| 290 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 291 | " <CustomTableRef Id=\"FgAppx\">", | ||
| 292 | " <Row>", | ||
| 293 | " <Data Column=\"Column1\" Value=\"Row1\" />", | ||
| 294 | " </Row>", | ||
| 295 | " </CustomTableRef>", | ||
| 296 | "</Wix>"); | ||
| 297 | |||
| 298 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 299 | |||
| 300 | var messaging = new MockMessaging(); | ||
| 301 | var converter = new WixConverter(messaging, 2, customTableTarget: CustomTableTarget.Msi); | ||
| 302 | |||
| 303 | var errors = converter.ConvertDocument(document); | ||
| 304 | |||
| 305 | var actual = UnformattedDocumentString(document); | ||
| 306 | |||
| 307 | Assert.Equal(2, errors); | ||
| 308 | Assert.Equal(expected, actual); | ||
| 309 | } | ||
| 310 | |||
| 311 | [Fact] | ||
| 312 | public void CanDetectAmbiguousCustomTableBootstrapperApplicationData() | ||
| 313 | { | ||
| 314 | var parse = String.Join(Environment.NewLine, | ||
| 315 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 316 | " <CustomTable Id='FgAppx' BootstrapperApplicationData='yes' />", | ||
| 317 | "</Wix>"); | ||
| 318 | |||
| 319 | var expected = String.Join(Environment.NewLine, | ||
| 320 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 321 | " <CustomTable Id=\"FgAppx\" BootstrapperApplicationData=\"yes\" />", | ||
| 322 | "</Wix>"); | ||
| 323 | |||
| 324 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 325 | |||
| 326 | var messaging = new MockMessaging(); | ||
| 327 | var converter = new WixConverter(messaging, 2); | ||
| 328 | |||
| 329 | var errors = converter.ConvertDocument(document); | ||
| 330 | |||
| 331 | var actual = UnformattedDocumentString(document); | ||
| 332 | |||
| 333 | Assert.Equal(1, errors); | ||
| 334 | Assert.Equal(expected, actual); | ||
| 335 | } | ||
| 336 | |||
| 337 | [Fact] | ||
| 338 | public void CanRemoveBootstrapperApplicationDataFromRealCustomTable() | ||
| 339 | { | ||
| 340 | var parse = String.Join(Environment.NewLine, | ||
| 341 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 342 | " <CustomTable Id='FgAppx' BootstrapperApplicationData='no' />", | ||
| 343 | "</Wix>"); | ||
| 344 | |||
| 345 | var expected = String.Join(Environment.NewLine, | ||
| 346 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
| 347 | " <CustomTable Id=\"FgAppx\" />", | ||
| 348 | "</Wix>"); | ||
| 349 | |||
| 350 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 351 | |||
| 352 | var messaging = new MockMessaging(); | ||
| 353 | var converter = new WixConverter(messaging, 2); | ||
| 354 | |||
| 355 | var errors = converter.ConvertDocument(document); | ||
| 356 | |||
| 357 | var actual = UnformattedDocumentString(document); | ||
| 358 | |||
| 359 | Assert.Equal(1, errors); | ||
| 360 | Assert.Equal(expected, actual); | ||
| 361 | } | ||
| 362 | } | ||
| 363 | } | ||
