diff options
author | Bevan Weiss <bevan.weiss@gmail.com> | 2024-07-15 20:06:54 +1000 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2024-07-18 09:59:43 -0700 |
commit | ce73352b1fa1d4f9cded10a0ee410f2e786bd326 (patch) | |
tree | 2f96b17fa23f8433cc3ff0f8e260c90122276358 /src/test/burn | |
parent | 8fb5d579e8cf5eb0f93d07a73bf318a8969c6b10 (diff) | |
download | wix-ce73352b1fa1d4f9cded10a0ee410f2e786bd326.tar.gz wix-ce73352b1fa1d4f9cded10a0ee410f2e786bd326.tar.bz2 wix-ce73352b1fa1d4f9cded10a0ee410f2e786bd326.zip |
Add basic test for Msmq install/uninstall.
Fix up lack of WIX CUSTOM_ACTION_DECORATION wrappers
Add new RuntimeTest skipper for Server Features / Optional Features.
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Diffstat (limited to 'src/test/burn')
-rw-r--r-- | src/test/burn/WixTestTools/RuntimePrereqFeatureFactAttribute.cs | 56 | ||||
-rw-r--r-- | src/test/burn/WixTestTools/WixTestTools.csproj | 1 |
2 files changed, 57 insertions, 0 deletions
diff --git a/src/test/burn/WixTestTools/RuntimePrereqFeatureFactAttribute.cs b/src/test/burn/WixTestTools/RuntimePrereqFeatureFactAttribute.cs new file mode 100644 index 00000000..aa02d5f3 --- /dev/null +++ b/src/test/burn/WixTestTools/RuntimePrereqFeatureFactAttribute.cs | |||
@@ -0,0 +1,56 @@ | |||
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.Globalization; | ||
7 | using System.Linq; | ||
8 | using System.Management; | ||
9 | using System.Collections.Generic; | ||
10 | using System.Security.Principal; | ||
11 | using WixInternal.TestSupport.XunitExtensions; | ||
12 | |||
13 | public class RuntimePrereqFeatureFactAttribute : RuntimeFactAttribute | ||
14 | { | ||
15 | public static HashSet<string> OptionalFeatures = new(StringComparer.OrdinalIgnoreCase); | ||
16 | public static HashSet<string> ServerFeatures = new(StringComparer.OrdinalIgnoreCase); | ||
17 | static RuntimePrereqFeatureFactAttribute() | ||
18 | { | ||
19 | AddFeaturesToSet(ServerFeatures, "Win32_ServerFeature"); | ||
20 | AddFeaturesToSet(OptionalFeatures, "Win32_OptionalFeature"); | ||
21 | } | ||
22 | |||
23 | private static void AddFeaturesToSet(HashSet<string> featureSet, string featureSetName) | ||
24 | { | ||
25 | try | ||
26 | { | ||
27 | var objMC = new ManagementClass(featureSetName); | ||
28 | var objMOC = objMC?.GetInstances(); | ||
29 | if (objMOC is not null) | ||
30 | { | ||
31 | foreach (var objMO in objMOC) | ||
32 | { | ||
33 | string featureName = (string)objMO.Properties["Name"].Value; | ||
34 | if ((uint)objMO.Properties["InstallState"].Value == 1) | ||
35 | { | ||
36 | featureSet.Add(featureName); | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | catch | ||
42 | { | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public RuntimePrereqFeatureFactAttribute(params string[] prerequisiteFeatures) : base() | ||
47 | { | ||
48 | var missingRequirements = prerequisiteFeatures.Select(x => x).Where(x => !ServerFeatures.Contains(x) && !OptionalFeatures.Contains(x)); | ||
49 | |||
50 | if (missingRequirements.Any()) | ||
51 | { | ||
52 | this.Skip = "This test is missing the following Feature pre-requisites: " + String.Join(", ", missingRequirements); | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | } | ||
diff --git a/src/test/burn/WixTestTools/WixTestTools.csproj b/src/test/burn/WixTestTools/WixTestTools.csproj index 19c09294..7a702949 100644 --- a/src/test/burn/WixTestTools/WixTestTools.csproj +++ b/src/test/burn/WixTestTools/WixTestTools.csproj | |||
@@ -23,6 +23,7 @@ | |||
23 | <PackageReference Include="Microsoft.Win32.Registry" /> | 23 | <PackageReference Include="Microsoft.Win32.Registry" /> |
24 | <PackageReference Include="System.DirectoryServices" /> | 24 | <PackageReference Include="System.DirectoryServices" /> |
25 | <PackageReference Include="System.DirectoryServices.AccountManagement" /> | 25 | <PackageReference Include="System.DirectoryServices.AccountManagement" /> |
26 | <PackageReference Include="System.Management" /> | ||
26 | <PackageReference Include="System.Security.Principal.Windows" /> | 27 | <PackageReference Include="System.Security.Principal.Windows" /> |
27 | <PackageReference Include="WixInternal.TestSupport" /> | 28 | <PackageReference Include="WixInternal.TestSupport" /> |
28 | <PackageReference Include="WixToolset.Data" /> | 29 | <PackageReference Include="WixToolset.Data" /> |