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 | |
| 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')
5 files changed, 114 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" /> |
diff --git a/src/test/msi/TestData/MsmqExtensionTests/MsmqInstall/MsmqInstall.wixproj b/src/test/msi/TestData/MsmqExtensionTests/MsmqInstall/MsmqInstall.wixproj new file mode 100644 index 00000000..41e39944 --- /dev/null +++ b/src/test/msi/TestData/MsmqExtensionTests/MsmqInstall/MsmqInstall.wixproj | |||
| @@ -0,0 +1,13 @@ | |||
| 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 | <Project Sdk="WixToolset.Sdk"> | ||
| 3 | <PropertyGroup> | ||
| 4 | <UpgradeCode>{A75B81F4-3335-4B4D-B766-303E136ED374}</UpgradeCode> | ||
| 5 | <ProductComponentsRef>true</ProductComponentsRef> | ||
| 6 | </PropertyGroup> | ||
| 7 | <ItemGroup> | ||
| 8 | <Compile Include="..\..\Templates\Product.wxs" Link="Product.wxs" /> | ||
| 9 | </ItemGroup> | ||
| 10 | <ItemGroup> | ||
| 11 | <PackageReference Include="WixToolset.Msmq.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> | ||
diff --git a/src/test/msi/TestData/MsmqExtensionTests/MsmqInstall/product.wxs b/src/test/msi/TestData/MsmqExtensionTests/MsmqInstall/product.wxs new file mode 100644 index 00000000..241b6aed --- /dev/null +++ b/src/test/msi/TestData/MsmqExtensionTests/MsmqInstall/product.wxs | |||
| @@ -0,0 +1,17 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:msmq="http://wixtoolset.org/schemas/v4/wxs/msmq"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | |||
| 11 | <Fragment> | ||
| 12 | <Component Id="Component1"> | ||
| 13 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 14 | <msmq:MessageQueue Id="ExampleQueue" PathName=".\private$\example-queue" Label="Example Queue" Transactional="yes" /> | ||
| 15 | </Component> | ||
| 16 | </Fragment> | ||
| 17 | </Wix> | ||
diff --git a/src/test/msi/WixToolsetTest.MsiE2E/MsmqExtensionTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/MsmqExtensionTests.cs new file mode 100644 index 00000000..41eb8201 --- /dev/null +++ b/src/test/msi/WixToolsetTest.MsiE2E/MsmqExtensionTests.cs | |||
| @@ -0,0 +1,27 @@ | |||
| 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.MsiE2E | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Linq; | ||
| 8 | using System.Text; | ||
| 9 | using System.Threading.Tasks; | ||
| 10 | using WixTestTools; | ||
| 11 | using Xunit.Abstractions; | ||
| 12 | |||
| 13 | public class MsmqExtensionTests : MsiE2ETests | ||
| 14 | { | ||
| 15 | public MsmqExtensionTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) | ||
| 16 | { | ||
| 17 | } | ||
| 18 | |||
| 19 | [RuntimePrereqFeatureFact("MSMQ-Container", "MSMQ-Server")] | ||
| 20 | public void CanInstallAndUninstallMsmq() | ||
| 21 | { | ||
| 22 | var product = this.CreatePackageInstaller("MsmqInstall"); | ||
| 23 | product.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 24 | product.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
