diff options
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs')
-rw-r--r-- | src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs | 140 |
1 files changed, 16 insertions, 124 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs b/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs index 9893a525..15082f2b 100644 --- a/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs | |||
@@ -6,14 +6,14 @@ namespace WixToolsetTest.CoreIntegration | |||
6 | using System.Xml.Linq; | 6 | using System.Xml.Linq; |
7 | using WixBuildTools.TestSupport; | 7 | using WixBuildTools.TestSupport; |
8 | using WixToolset.Core.TestPackage; | 8 | using WixToolset.Core.TestPackage; |
9 | using WixToolset.Extensibility.Services; | ||
9 | using Xunit; | 10 | using Xunit; |
10 | 11 | ||
11 | public class DecompileFixture | 12 | public class DecompileFixture |
12 | { | 13 | { |
13 | [Fact] | 14 | private static void DecompileAndCompare(string sourceFolder, string msiName, string expectedWxsName) |
14 | public void CanDecompileSingleFileCompressed() | ||
15 | { | 15 | { |
16 | var folder = TestData.Get(@"TestData\DecompileSingleFileCompressed"); | 16 | var folder = TestData.Get(sourceFolder); |
17 | 17 | ||
18 | using (var fs = new DisposableFileSystem()) | 18 | using (var fs = new DisposableFileSystem()) |
19 | { | 19 | { |
@@ -23,75 +23,33 @@ namespace WixToolsetTest.CoreIntegration | |||
23 | var result = WixRunner.Execute(new[] | 23 | var result = WixRunner.Execute(new[] |
24 | { | 24 | { |
25 | "decompile", | 25 | "decompile", |
26 | Path.Combine(folder, "example.msi"), | 26 | Path.Combine(folder, msiName), |
27 | "-intermediateFolder", intermediateFolder, | 27 | "-intermediateFolder", intermediateFolder, |
28 | "-o", outputPath | 28 | "-o", outputPath |
29 | }); | 29 | }); |
30 | 30 | ||
31 | result.AssertSuccess(); | 31 | result.AssertSuccess(); |
32 | 32 | ||
33 | var actual = File.ReadAllText(outputPath); | 33 | WixAssert.CompareXml(Path.Combine(folder, expectedWxsName), outputPath); |
34 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
35 | var expected = XDocument.Load(Path.Combine(folder, "Expected.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
36 | |||
37 | Assert.Equal(expected, actualFormatted); | ||
38 | } | 34 | } |
39 | } | 35 | } |
40 | 36 | ||
41 | [Fact] | 37 | [Fact] |
42 | public void CanDecompile64BitSingleFileCompressed() | 38 | public void CanDecompileSingleFileCompressed() |
43 | { | 39 | { |
44 | var folder = TestData.Get(@"TestData\DecompileSingleFileCompressed64"); | 40 | DecompileAndCompare(@"TestData\DecompileSingleFileCompressed", "example.msi", "Expected.wxs"); |
45 | 41 | } | |
46 | using (var fs = new DisposableFileSystem()) | ||
47 | { | ||
48 | var intermediateFolder = fs.GetFolder(); | ||
49 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
50 | |||
51 | var result = WixRunner.Execute(new[] | ||
52 | { | ||
53 | "decompile", | ||
54 | Path.Combine(folder, "example.msi"), | ||
55 | "-intermediateFolder", intermediateFolder, | ||
56 | "-o", outputPath | ||
57 | }); | ||
58 | |||
59 | result.AssertSuccess(); | ||
60 | |||
61 | var actual = File.ReadAllText(outputPath); | ||
62 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
63 | var expected = XDocument.Load(Path.Combine(folder, "Expected.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
64 | 42 | ||
65 | Assert.Equal(expected, actualFormatted); | 43 | [Fact] |
66 | } | 44 | public void CanDecompile64BitSingleFileCompressed() |
45 | { | ||
46 | DecompileAndCompare(@"TestData\DecompileSingleFileCompressed64", "example.msi", "Expected.wxs"); | ||
67 | } | 47 | } |
68 | 48 | ||
69 | [Fact] | 49 | [Fact] |
70 | public void CanDecompileNestedDirSearchUnderRegSearch() | 50 | public void CanDecompileNestedDirSearchUnderRegSearch() |
71 | { | 51 | { |
72 | var folder = TestData.Get(@"TestData\AppSearch"); | 52 | DecompileAndCompare(@"TestData\AppSearch", "NestedDirSearchUnderRegSearch.msi", "DecompiledNestedDirSearchUnderRegSearch.wxs"); |
73 | |||
74 | using (var fs = new DisposableFileSystem()) | ||
75 | { | ||
76 | var intermediateFolder = fs.GetFolder(); | ||
77 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
78 | |||
79 | var result = WixRunner.Execute(new[] | ||
80 | { | ||
81 | "decompile", | ||
82 | Path.Combine(folder, "NestedDirSearchUnderRegSearch.msi"), | ||
83 | "-intermediateFolder", intermediateFolder, | ||
84 | "-o", outputPath | ||
85 | }); | ||
86 | |||
87 | result.AssertSuccess(); | ||
88 | |||
89 | var actual = File.ReadAllText(outputPath); | ||
90 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
91 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledNestedDirSearchUnderRegSearch.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
92 | |||
93 | Assert.Equal(expected, actualFormatted); | ||
94 | } | ||
95 | } | 53 | } |
96 | 54 | ||
97 | [Fact] | 55 | [Fact] |
@@ -100,85 +58,19 @@ namespace WixToolsetTest.CoreIntegration | |||
100 | // The input MSI was not created using standard methods, it is an example of a real world database that needs to be decompiled. | 58 | // The input MSI was not created using standard methods, it is an example of a real world database that needs to be decompiled. |
101 | // The Class/@Feature_ column has length of 32, the File/@Attributes has length of 2, | 59 | // The Class/@Feature_ column has length of 32, the File/@Attributes has length of 2, |
102 | // and numerous foreign key relationships are missing. | 60 | // and numerous foreign key relationships are missing. |
103 | var folder = TestData.Get(@"TestData\Class"); | 61 | DecompileAndCompare(@"TestData\Class", "OldClassTableDef.msi", "DecompiledOldClassTableDef.wxs"); |
104 | |||
105 | using (var fs = new DisposableFileSystem()) | ||
106 | { | ||
107 | var intermediateFolder = fs.GetFolder(); | ||
108 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
109 | |||
110 | var result = WixRunner.Execute(new[] | ||
111 | { | ||
112 | "decompile", | ||
113 | Path.Combine(folder, "OldClassTableDef.msi"), | ||
114 | "-intermediateFolder", intermediateFolder, | ||
115 | "-o", outputPath | ||
116 | }); | ||
117 | |||
118 | result.AssertSuccess(); | ||
119 | |||
120 | var actual = File.ReadAllText(outputPath); | ||
121 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
122 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledOldClassTableDef.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
123 | |||
124 | Assert.Equal(expected, actualFormatted); | ||
125 | } | ||
126 | } | 62 | } |
127 | 63 | ||
128 | [Fact] | 64 | [Fact] |
129 | public void CanDecompileSequenceTables() | 65 | public void CanDecompileSequenceTables() |
130 | { | 66 | { |
131 | var folder = TestData.Get(@"TestData\SequenceTables"); | 67 | DecompileAndCompare(@"TestData\SequenceTables", "SequenceTables.msi", "DecompiledSequenceTables.wxs"); |
132 | |||
133 | using (var fs = new DisposableFileSystem()) | ||
134 | { | ||
135 | var intermediateFolder = fs.GetFolder(); | ||
136 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
137 | |||
138 | var result = WixRunner.Execute(new[] | ||
139 | { | ||
140 | "decompile", | ||
141 | Path.Combine(folder, "SequenceTables.msi"), | ||
142 | "-intermediateFolder", intermediateFolder, | ||
143 | "-o", outputPath | ||
144 | }); | ||
145 | |||
146 | result.AssertSuccess(); | ||
147 | |||
148 | var actual = File.ReadAllText(outputPath); | ||
149 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
150 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledSequenceTables.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
151 | |||
152 | Assert.Equal(expected, actualFormatted); | ||
153 | } | ||
154 | } | 68 | } |
155 | 69 | ||
156 | [Fact] | 70 | [Fact] |
157 | public void CanDecompileShortcuts() | 71 | public void CanDecompileShortcuts() |
158 | { | 72 | { |
159 | var folder = TestData.Get(@"TestData\Shortcut"); | 73 | DecompileAndCompare(@"TestData\Shortcut", "shortcuts.msi", "DecompiledShortcuts.wxs"); |
160 | |||
161 | using (var fs = new DisposableFileSystem()) | ||
162 | { | ||
163 | var intermediateFolder = fs.GetFolder(); | ||
164 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
165 | |||
166 | var result = WixRunner.Execute(new[] | ||
167 | { | ||
168 | "decompile", | ||
169 | Path.Combine(folder, "shortcuts.msi"), | ||
170 | "-intermediateFolder", intermediateFolder, | ||
171 | "-o", outputPath | ||
172 | }); | ||
173 | |||
174 | result.AssertSuccess(); | ||
175 | |||
176 | var actual = File.ReadAllText(outputPath); | ||
177 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
178 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledShortcuts.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
179 | |||
180 | Assert.Equal(expected, actualFormatted); | ||
181 | } | ||
182 | } | 74 | } |
183 | } | 75 | } |
184 | } | 76 | } |