diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-06-12 06:51:37 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-06-12 08:20:50 -0700 |
| commit | 49ce77951ca980848b275cef082309c49b117f47 (patch) | |
| tree | a57e22fef0451b65edf6744440b84af04704c9e7 /src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs | |
| parent | a82e58ab8a47f4b5d189213da4d7c1dea8437972 (diff) | |
| download | wix-49ce77951ca980848b275cef082309c49b117f47.tar.gz wix-49ce77951ca980848b275cef082309c49b117f47.tar.bz2 wix-49ce77951ca980848b275cef082309c49b117f47.zip | |
Fix custom table column values case in compiler and decompiler
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs')
| -rw-r--r-- | src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs b/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs new file mode 100644 index 00000000..85a0ffae --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs | |||
| @@ -0,0 +1,244 @@ | |||
| 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.CoreIntegration | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using Microsoft.Build.Tasks; | ||
| 7 | using WixBuildTools.TestSupport; | ||
| 8 | using WixToolset.Core.TestPackage; | ||
| 9 | using Xunit; | ||
| 10 | |||
| 11 | public class CustomTableFixture | ||
| 12 | { | ||
| 13 | [Fact] | ||
| 14 | public void PopulatesCustomTable1() | ||
| 15 | { | ||
| 16 | var folder = TestData.Get(@"TestData"); | ||
| 17 | |||
| 18 | using (var fs = new DisposableFileSystem()) | ||
| 19 | { | ||
| 20 | var baseFolder = fs.GetFolder(); | ||
| 21 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 22 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
| 23 | |||
| 24 | var result = WixRunner.Execute(new[] | ||
| 25 | { | ||
| 26 | "build", | ||
| 27 | Path.Combine(folder, "CustomTable", "CustomTable.wxs"), | ||
| 28 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
| 29 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
| 30 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
| 31 | "-intermediateFolder", intermediateFolder, | ||
| 32 | "-o", msiPath | ||
| 33 | }); | ||
| 34 | |||
| 35 | result.AssertSuccess(); | ||
| 36 | |||
| 37 | Assert.True(File.Exists(msiPath)); | ||
| 38 | var results = Query.QueryDatabase(msiPath, new[] { "CustomTable1" }); | ||
| 39 | Assert.Equal(new[] | ||
| 40 | { | ||
| 41 | "CustomTable1:Row1\ttest.txt", | ||
| 42 | "CustomTable1:Row2\ttest.txt", | ||
| 43 | }, results); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | [Fact] | ||
| 48 | public void PopulatesCustomTableWithLocalization() | ||
| 49 | { | ||
| 50 | var folder = TestData.Get(@"TestData"); | ||
| 51 | |||
| 52 | using (var fs = new DisposableFileSystem()) | ||
| 53 | { | ||
| 54 | var baseFolder = fs.GetFolder(); | ||
| 55 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 56 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
| 57 | |||
| 58 | var result = WixRunner.Execute(new[] | ||
| 59 | { | ||
| 60 | "build", | ||
| 61 | Path.Combine(folder, "CustomTable", "LocalizedCustomTable.wxs"), | ||
| 62 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
| 63 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
| 64 | "-loc", Path.Combine(folder, "CustomTable", "LocalizedCustomTable.en-us.wxl"), | ||
| 65 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
| 66 | "-intermediateFolder", intermediateFolder, | ||
| 67 | "-o", msiPath | ||
| 68 | }); | ||
| 69 | |||
| 70 | result.AssertSuccess(); | ||
| 71 | |||
| 72 | Assert.True(File.Exists(msiPath)); | ||
| 73 | var results = Query.QueryDatabase(msiPath, new[] { "CustomTableLocalized" }); | ||
| 74 | Assert.Equal(new[] | ||
| 75 | { | ||
| 76 | "CustomTableLocalized:Row1\tThis is row one", | ||
| 77 | "CustomTableLocalized:Row2\tThis is row two", | ||
| 78 | }, results); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | [Fact] | ||
| 83 | public void PopulatesCustomTableWithFilePath() | ||
| 84 | { | ||
| 85 | var folder = TestData.Get(@"TestData"); | ||
| 86 | |||
| 87 | using (var fs = new DisposableFileSystem()) | ||
| 88 | { | ||
| 89 | var baseFolder = fs.GetFolder(); | ||
| 90 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 91 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
| 92 | |||
| 93 | var result = WixRunner.Execute(new[] | ||
| 94 | { | ||
| 95 | "build", | ||
| 96 | Path.Combine(folder, "CustomTable", "CustomTableWithFile.wxs"), | ||
| 97 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
| 98 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
| 99 | "-bindpath", Path.Combine(folder, "CustomTable", "data"), | ||
| 100 | "-intermediateFolder", intermediateFolder, | ||
| 101 | "-o", msiPath | ||
| 102 | }); | ||
| 103 | |||
| 104 | result.AssertSuccess(); | ||
| 105 | |||
| 106 | Assert.True(File.Exists(msiPath)); | ||
| 107 | var results = Query.QueryDatabase(msiPath, new[] { "CustomTableWithFile" }); | ||
| 108 | Assert.Equal(new[] | ||
| 109 | { | ||
| 110 | "CustomTableWithFile:Row1\t[Binary data]", | ||
| 111 | "CustomTableWithFile:Row2\t[Binary data]", | ||
| 112 | }, results); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | [Fact] | ||
| 117 | public void PopulatesCustomTableWithFilePathSerialized() | ||
| 118 | { | ||
| 119 | var folder = TestData.Get(@"TestData"); | ||
| 120 | |||
| 121 | using (var fs = new DisposableFileSystem()) | ||
| 122 | { | ||
| 123 | var baseFolder = fs.GetFolder(); | ||
| 124 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 125 | var wixlibPath = Path.Combine(baseFolder, @"bin\test.wixlib"); | ||
| 126 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
| 127 | |||
| 128 | var result = WixRunner.Execute(new[] | ||
| 129 | { | ||
| 130 | "build", | ||
| 131 | Path.Combine(folder, "CustomTable", "CustomTableWithFile.wxs"), | ||
| 132 | "-bindpath", Path.Combine(folder, "CustomTable", "data"), | ||
| 133 | "-intermediateFolder", intermediateFolder, | ||
| 134 | "-o", wixlibPath | ||
| 135 | }); | ||
| 136 | |||
| 137 | result.AssertSuccess(); | ||
| 138 | |||
| 139 | result = WixRunner.Execute(new[] | ||
| 140 | { | ||
| 141 | "build", | ||
| 142 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
| 143 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
| 144 | "-lib", wixlibPath, | ||
| 145 | "-bindpath", Path.Combine(folder, "CustomTable", "data"), | ||
| 146 | "-intermediateFolder", intermediateFolder, | ||
| 147 | "-o", msiPath | ||
| 148 | }); | ||
| 149 | |||
| 150 | result.AssertSuccess(); | ||
| 151 | |||
| 152 | Assert.True(File.Exists(msiPath)); | ||
| 153 | var results = Query.QueryDatabase(msiPath, new[] { "CustomTableWithFile" }); | ||
| 154 | Assert.Equal(new[] | ||
| 155 | { | ||
| 156 | "CustomTableWithFile:Row1\t[Binary data]", | ||
| 157 | "CustomTableWithFile:Row2\t[Binary data]", | ||
| 158 | }, results); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | [Fact] | ||
| 163 | public void UnrealCustomTableIsNotPresentInMsi() | ||
| 164 | { | ||
| 165 | var folder = TestData.Get(@"TestData"); | ||
| 166 | |||
| 167 | using (var fs = new DisposableFileSystem()) | ||
| 168 | { | ||
| 169 | var baseFolder = fs.GetFolder(); | ||
| 170 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 171 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
| 172 | |||
| 173 | var result = WixRunner.Execute(new[] | ||
| 174 | { | ||
| 175 | "build", | ||
| 176 | Path.Combine(folder, "CustomTable", "CustomTable.wxs"), | ||
| 177 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
| 178 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
| 179 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
| 180 | "-intermediateFolder", intermediateFolder, | ||
| 181 | "-o", msiPath | ||
| 182 | }); | ||
| 183 | |||
| 184 | result.AssertSuccess(); | ||
| 185 | |||
| 186 | Assert.True(File.Exists(msiPath)); | ||
| 187 | var results = Query.QueryDatabase(msiPath, new[] { "CustomTable2" }); | ||
| 188 | Assert.Empty(results); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | [Fact] | ||
| 193 | public void CanCompileAndDecompile() | ||
| 194 | { | ||
| 195 | var folder = TestData.Get(@"TestData"); | ||
| 196 | var expectedFile = Path.Combine(folder, "CustomTable", "CustomTable-Expected.wxs"); | ||
| 197 | |||
| 198 | using (var fs = new DisposableFileSystem()) | ||
| 199 | { | ||
| 200 | var baseFolder = fs.GetFolder(); | ||
| 201 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 202 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
| 203 | var decompiledWxsPath = Path.Combine(baseFolder, @"decompiled.wxs"); | ||
| 204 | |||
| 205 | var result = WixRunner.Execute(new[] | ||
| 206 | { | ||
| 207 | "build", | ||
| 208 | Path.Combine(folder, "CustomTable", "CustomTable.wxs"), | ||
| 209 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
| 210 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
| 211 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
| 212 | "-intermediateFolder", intermediateFolder, | ||
| 213 | "-o", msiPath | ||
| 214 | }); | ||
| 215 | |||
| 216 | result.AssertSuccess(); | ||
| 217 | Assert.True(File.Exists(msiPath)); | ||
| 218 | |||
| 219 | result = WixRunner.Execute(new[] | ||
| 220 | { | ||
| 221 | "decompile", msiPath, | ||
| 222 | "-intermediateFolder", intermediateFolder, | ||
| 223 | "-o", decompiledWxsPath | ||
| 224 | }); | ||
| 225 | |||
| 226 | result.AssertSuccess(); | ||
| 227 | |||
| 228 | CompareLineByLine(expectedFile, decompiledWxsPath); | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | private static void CompareLineByLine(string expectedFile, string actualFile) | ||
| 233 | { | ||
| 234 | var expectedLines = File.ReadAllLines(expectedFile); | ||
| 235 | var actualLines = File.ReadAllLines(actualFile); | ||
| 236 | for (var i = 0; i < expectedLines.Length; ++i) | ||
| 237 | { | ||
| 238 | Assert.True(actualLines.Length > i, $"{i}: Expected file longer than actual file"); | ||
| 239 | Assert.Equal($"{i}: {expectedLines[i]}", $"{i}: {actualLines[i]}"); | ||
| 240 | } | ||
| 241 | Assert.True(expectedLines.Length == actualLines.Length, "Actual file longer than expected file"); | ||
| 242 | } | ||
| 243 | } | ||
| 244 | } | ||
