diff options
Diffstat (limited to 'src/test/burn/WixTestTools/PackageVerifier.cs')
-rw-r--r-- | src/test/burn/WixTestTools/PackageVerifier.cs | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/test/burn/WixTestTools/PackageVerifier.cs b/src/test/burn/WixTestTools/PackageVerifier.cs new file mode 100644 index 00000000..2f42dd21 --- /dev/null +++ b/src/test/burn/WixTestTools/PackageVerifier.cs | |||
@@ -0,0 +1,81 @@ | |||
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 WixTestTools | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using System.Linq; | ||
8 | using WixToolset.Data.WindowsInstaller; | ||
9 | using WixToolset.Data.WindowsInstaller.Rows; | ||
10 | using Xunit; | ||
11 | |||
12 | public partial class PackageInstaller | ||
13 | { | ||
14 | public string PackagePdb { get; } | ||
15 | |||
16 | private bool IsX64 { get; } | ||
17 | |||
18 | private WindowsInstallerData WiData { get; } | ||
19 | |||
20 | public string GetInstalledFilePath(string filename) | ||
21 | { | ||
22 | return this.TestContext.GetTestInstallFolder(this.IsX64, Path.Combine(this.GetInstallFolderName(), filename)); | ||
23 | } | ||
24 | |||
25 | public string GetInstallFolderName() | ||
26 | { | ||
27 | var row = this.WiData.Tables["Directory"].Rows.Single(r => r.FieldAsString(0) == "INSTALLFOLDER"); | ||
28 | var value = row.FieldAsString(2); | ||
29 | var longNameIndex = value.IndexOf('|') + 1; | ||
30 | if (longNameIndex > 0) | ||
31 | { | ||
32 | return value.Substring(longNameIndex); | ||
33 | } | ||
34 | return value; | ||
35 | } | ||
36 | |||
37 | public string GetProperty(string name) | ||
38 | { | ||
39 | var row = this.WiData.Tables["Property"].Rows.Cast<PropertyRow>().Single(r => r.Property == name); | ||
40 | return row.Value; | ||
41 | } | ||
42 | |||
43 | public void VerifyInstalled(bool installed) | ||
44 | { | ||
45 | var productCode = this.GetProperty("ProductCode"); | ||
46 | Assert.Equal(installed, MsiUtilities.IsProductInstalled(productCode)); | ||
47 | } | ||
48 | |||
49 | public void VerifyInstalledWithVersion(bool installed) | ||
50 | { | ||
51 | var productCode = this.GetProperty("ProductCode"); | ||
52 | Version prodVersion = new Version(this.GetProperty("ProductVersion")); | ||
53 | Assert.Equal(installed, MsiUtilities.IsProductInstalledWithVersion(productCode, prodVersion)); | ||
54 | } | ||
55 | |||
56 | public void DeleteTestRegistryValue(string name) | ||
57 | { | ||
58 | using (var root = this.TestContext.GetTestRegistryRoot(this.IsX64)) | ||
59 | { | ||
60 | Assert.NotNull(root); | ||
61 | root.DeleteValue(name); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public void VerifyTestRegistryRootDeleted() | ||
66 | { | ||
67 | using var testRegistryRoot = this.TestContext.GetTestRegistryRoot(this.IsX64); | ||
68 | Assert.Null(testRegistryRoot); | ||
69 | } | ||
70 | |||
71 | public void VerifyTestRegistryValue(string name, string expectedValue) | ||
72 | { | ||
73 | using (var root = this.TestContext.GetTestRegistryRoot(this.IsX64)) | ||
74 | { | ||
75 | Assert.NotNull(root); | ||
76 | var actualValue = root.GetValue(name) as string; | ||
77 | Assert.Equal(expectedValue, actualValue); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | } | ||