diff options
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs')
-rw-r--r-- | src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs new file mode 100644 index 00000000..349bad2c --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/ModuleFixture.cs | |||
@@ -0,0 +1,108 @@ | |||
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; | ||
6 | using System.IO; | ||
7 | using System.Linq; | ||
8 | using WixBuildTools.TestSupport; | ||
9 | using WixToolset.Core.TestPackage; | ||
10 | using WixToolset.Data; | ||
11 | using WixToolset.Data.Symbols; | ||
12 | using WixToolset.Data.WindowsInstaller; | ||
13 | using Xunit; | ||
14 | |||
15 | public class ModuleFixture | ||
16 | { | ||
17 | [Fact] | ||
18 | public void CanBuildSimpleModule() | ||
19 | { | ||
20 | var folder = TestData.Get(@"TestData\SimpleModule"); | ||
21 | |||
22 | using (var fs = new DisposableFileSystem()) | ||
23 | { | ||
24 | var intermediateFolder = fs.GetFolder(); | ||
25 | |||
26 | var result = WixRunner.Execute(new[] | ||
27 | { | ||
28 | "build", | ||
29 | Path.Combine(folder, "Module.wxs"), | ||
30 | "-loc", Path.Combine(folder, "Module.en-us.wxl"), | ||
31 | "-bindpath", Path.Combine(folder, "data"), | ||
32 | "-intermediateFolder", intermediateFolder, | ||
33 | "-o", Path.Combine(intermediateFolder, @"bin\test.msm") | ||
34 | }); | ||
35 | |||
36 | result.AssertSuccess(); | ||
37 | |||
38 | var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm"); | ||
39 | Assert.True(File.Exists(msmPath)); | ||
40 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); | ||
41 | |||
42 | var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb")); | ||
43 | var section = intermediate.Sections.Single(); | ||
44 | |||
45 | var dirSymbols = section.Symbols.OfType<DirectorySymbol>().OrderBy(d => d.Id.Id).ToList(); | ||
46 | WixAssert.CompareLineByLine(new[] | ||
47 | { | ||
48 | "MergeRedirectFolder\tTARGETDIR\t.", | ||
49 | "TARGETDIR\t\tSourceDir" | ||
50 | }, dirSymbols.Select(d => String.Join("\t", d.Id.Id, d.ParentDirectoryRef, d.Name)).ToArray()); | ||
51 | |||
52 | var fileSymbol = section.Symbols.OfType<FileSymbol>().Single(); | ||
53 | Assert.Equal("filyIq8rqcxxf903Hsn5K9L0SWV73g", fileSymbol.Id.Id); | ||
54 | Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path); | ||
55 | Assert.Equal(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path); | ||
56 | |||
57 | var data = WindowsInstallerData.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb")); | ||
58 | var fileRows = data.Tables["File"].Rows; | ||
59 | Assert.Equal(new[] | ||
60 | { | ||
61 | "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE" | ||
62 | }, fileRows.Select(r => r.FieldAsString(0)).ToArray()); | ||
63 | |||
64 | var cabPath = Path.Combine(intermediateFolder, "msm-test.cab"); | ||
65 | Query.ExtractStream(msmPath, "MergeModule.CABinet", cabPath); | ||
66 | var files = Query.GetCabinetFiles(cabPath); | ||
67 | Assert.Equal(new[] | ||
68 | { | ||
69 | "filyIq8rqcxxf903Hsn5K9L0SWV73g.243FB739_4D05_472F_9CFB_EF6B1017B6DE" | ||
70 | }, files.Select(f => Path.Combine(f.Path, f.Name)).ToArray()); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | [Fact] | ||
75 | public void CanSuppressModularization() | ||
76 | { | ||
77 | var folder = TestData.Get(@"TestData\SuppressModularization"); | ||
78 | |||
79 | using (var fs = new DisposableFileSystem()) | ||
80 | { | ||
81 | var intermediateFolder = fs.GetFolder(); | ||
82 | |||
83 | var result = WixRunner.Execute(new[] | ||
84 | { | ||
85 | "build", | ||
86 | Path.Combine(folder, "Module.wxs"), | ||
87 | "-loc", Path.Combine(folder, "Module.en-us.wxl"), | ||
88 | "-bindpath", Path.Combine(folder, "data"), | ||
89 | "-intermediateFolder", intermediateFolder, | ||
90 | "-sw1079", | ||
91 | "-sw1086", | ||
92 | "-o", Path.Combine(intermediateFolder, @"bin\test.msm") | ||
93 | }); | ||
94 | |||
95 | result.AssertSuccess(); | ||
96 | |||
97 | var msmPath = Path.Combine(intermediateFolder, @"bin\test.msm"); | ||
98 | |||
99 | var rows = Query.QueryDatabase(msmPath, new[] { "CustomAction", "Property" }); | ||
100 | WixAssert.CompareLineByLine(new[] | ||
101 | { | ||
102 | "CustomAction:Test\t11265\tFakeCA.243FB739_4D05_472F_9CFB_EF6B1017B6DE\tTestEntry\t", | ||
103 | "Property:MsiHiddenProperties\tTest" | ||
104 | }, rows); | ||
105 | } | ||
106 | } | ||
107 | } | ||
108 | } | ||