Skip to content

Commit

Permalink
Merge pull request #21 from MartinKuschnik/20-arrays-of-iunknown-not-…
Browse files Browse the repository at this point in the history
…working

Added support for Arrays of IUnknown
  • Loading branch information
MartinKuschnik authored Jul 19, 2024
2 parents 9094c44 + 71cbe96 commit 76aa424
Show file tree
Hide file tree
Showing 18 changed files with 4,125 additions and 202 deletions.
8 changes: 4 additions & 4 deletions WmiLight.Native/WmiLight.Native.rc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 6,1,1,0
PRODUCTVERSION 6,1,1,0
FILEVERSION 6,2,0,0
PRODUCTVERSION 6,2,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -61,12 +61,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Martin Kuschnik"
VALUE "FileDescription", "The native part of the WmiLight lib."
VALUE "FileVersion", "6.1.1.0"
VALUE "FileVersion", "6.2.0.0"
VALUE "InternalName", "WmiLight.Native"
VALUE "LegalCopyright", "Copyright 2024 Martin Kuschnik"
VALUE "OriginalFilename", "WmiLight.Native.dll"
VALUE "ProductName", "WmiLight"
VALUE "ProductVersion", "6.1.1.0"
VALUE "ProductVersion", "6.2.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down
442 changes: 442 additions & 0 deletions WmiLight.UnitTests/MSFT_Volume.cs

Large diffs are not rendered by default.

814 changes: 814 additions & 0 deletions WmiLight.UnitTests/Msvm_ComputerSystem.cs

Large diffs are not rendered by default.

845 changes: 845 additions & 0 deletions WmiLight.UnitTests/Msvm_SummaryInformation.cs

Large diffs are not rendered by default.

256 changes: 256 additions & 0 deletions WmiLight.UnitTests/Msvm_VirtualSystemCapabilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
using System.Management;

namespace WmiLight.UnitTests
{
[TestClass]
public class Msvm_VirtualSystemCapabilities
{
[TestMethod]
public void Msvm_VirtualSystemCapabilities_Caption_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.String>(msObject, wmiObject, "Caption");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_Caption_Is_String()
{
const string PropertyName = "Caption";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.String>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.String>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.String genericValue = wmiObject.GetPropertyValue<System.String>(PropertyName);
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_Description_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.String>(msObject, wmiObject, "Description");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_Description_Is_String()
{
const string PropertyName = "Description";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.String>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.String>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.String genericValue = wmiObject.GetPropertyValue<System.String>(PropertyName);
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_ElementName_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.String>(msObject, wmiObject, "ElementName");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_ElementName_Is_String()
{
const string PropertyName = "ElementName";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.String>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.String>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.String genericValue = wmiObject.GetPropertyValue<System.String>(PropertyName);
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_ElementNameEditSupported_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.Boolean>(msObject, wmiObject, "ElementNameEditSupported");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_ElementNameEditSupported_Is_Boolean()
{
const string PropertyName = "ElementNameEditSupported";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.Boolean>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.Boolean>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.Boolean genericValue = wmiObject.GetPropertyValue<System.Boolean>(PropertyName);
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_ElementNameMask_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.String>(msObject, wmiObject, "ElementNameMask");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_ElementNameMask_Is_String()
{
const string PropertyName = "ElementNameMask";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.String>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.String>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.String genericValue = wmiObject.GetPropertyValue<System.String>(PropertyName);
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_InstanceID_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.String>(msObject, wmiObject, "InstanceID");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_InstanceID_Is_String()
{
const string PropertyName = "InstanceID";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.String>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.String>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.String genericValue = wmiObject.GetPropertyValue<System.String>(PropertyName);
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_MaxElementNameLen_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.UInt16>(msObject, wmiObject, "MaxElementNameLen");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_MaxElementNameLen_Is_UInt16()
{
const string PropertyName = "MaxElementNameLen";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.UInt16>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.UInt16>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.UInt16 genericValue = wmiObject.GetPropertyValue<System.UInt16>(PropertyName);
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_RequestedStatesSupported_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
WmiAssert.AreEqual<System.UInt16[]>(msObject, wmiObject, "RequestedStatesSupported");
}
}

[TestMethod]
public void Msvm_VirtualSystemCapabilities_RequestedStatesSupported_Is_UInt16Array()
{
const string PropertyName = "RequestedStatesSupported";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\virtualization\v2", "Msvm_VirtualSystemCapabilities"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.UInt16[]>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.UInt16[]>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.UInt16[] genericValue = wmiObject.GetPropertyValue<System.UInt16[]>(PropertyName);
}
}
}
}
93 changes: 93 additions & 0 deletions WmiLight.UnitTests/Win32_Desktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,98 @@ public void Win32_Desktop_WallpaperStretched_Is_Boolean()
System.Boolean genericValue = wmiObject.GetPropertyValue<System.Boolean>(PropertyName);
}
}

[TestMethod]
public void Win32_Desktop_Wallpaper_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\cimv2", "Win32_Desktop"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\cimv2", "Win32_Desktop"))
{
WmiAssert.AreEqual<System.String>(msObject, wmiObject, "Wallpaper");
}
}

[TestMethod]
public void Win32_Desktop_Wallpaper_Is_String()
{
const string PropertyName = "Wallpaper";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\cimv2", "Win32_Desktop"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.String>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.String>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.String genericValue = wmiObject.GetPropertyValue<System.String>(PropertyName);
}
}

[TestMethod]
public void Win32_Desktop_WallpaperTiled_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\cimv2", "Win32_Desktop"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\cimv2", "Win32_Desktop"))
{
WmiAssert.AreEqual<System.Boolean>(msObject, wmiObject, "WallpaperTiled");
}
}

[TestMethod]
public void Win32_Desktop_WallpaperTiled_Is_Boolean()
{
const string PropertyName = "WallpaperTiled";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\cimv2", "Win32_Desktop"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.Boolean>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.Boolean>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.Boolean genericValue = wmiObject.GetPropertyValue<System.Boolean>(PropertyName);
}
}

[TestMethod]
public void Win32_Desktop_IconSpacing_Is_Equal_To_System_Management()
{
using (ManagementBaseObject msObject = WmiHelper.GetFirstSystemManagementObjects(@"root\cimv2", "Win32_Desktop"))
using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\cimv2", "Win32_Desktop"))
{
WmiAssert.AreEqual<System.UInt32>(msObject, wmiObject, "IconSpacing");
}
}

[TestMethod]
public void Win32_Desktop_IconSpacing_Is_UInt32()
{
const string PropertyName = "IconSpacing";

using (WmiObject wmiObject = WmiHelper.GetFirstWmiLightObjects(@"root\cimv2", "Win32_Desktop"))
{
object indexerValue = wmiObject[PropertyName];

if (indexerValue != null)
Assert.IsInstanceOfType<System.UInt32>(indexerValue, $"{nameof(WmiObject)}[\"{PropertyName}\"] returned an unexpected type.");

object noneGenericValue = wmiObject.GetPropertyValue(PropertyName);

if (noneGenericValue != null)
Assert.IsInstanceOfType<System.UInt32>(noneGenericValue, $"{nameof(WmiObject)}.{nameof(wmiObject.GetPropertyValue)}(\"{PropertyName}\") returned an unexpected type.");

System.UInt32 genericValue = wmiObject.GetPropertyValue<System.UInt32>(PropertyName);
}
}
}
}
Loading

0 comments on commit 76aa424

Please sign in to comment.