Skip to content

Commit

Permalink
added argument validation to WmiAssert
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKuschnik committed Mar 19, 2024
1 parent a618c4d commit 53a6972
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions WmiLight.UnitTests/Helpers/WmiAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ internal static class WmiAssert
{
internal static void AreEqual<T>(ManagementBaseObject msObject, WmiObject wmiObject, string propertyName)
{
if (msObject is null)
{
throw new ArgumentNullException(nameof(msObject));
}

if (wmiObject is null)
{
throw new ArgumentNullException(nameof(wmiObject));
}

if (string.IsNullOrEmpty(propertyName))
{
throw new ArgumentException($"'{nameof(propertyName)}' cannot be null or empty.", nameof(propertyName));
}

if (typeof(T).IsArray)
{
CollectionAssert.AreEqual((T)msObject.GetPropertyValue(propertyName) as ICollection, wmiObject.GetPropertyValue<T>(propertyName) as ICollection);
Expand Down

0 comments on commit 53a6972

Please sign in to comment.