0.9.3
What is new in 0.9.3
?
-Verbose
parameter to Assert-Equivalence
Comparing big objects with many properties is very difficult to debug when you don't see what exactly is happening. So Assert-Equivalent
now has a -Verbose
switch that shows where in the object we are, if there was a difference or equivalence, and other verbose information about what is happening.
( The feature is mostly done, all types are logging, except for DataTable and DataRow.)
Example:
Import-Module -Name Assert -RequiredVersion 0.9.3
function Get-Object () {
[PSCustomObject]@{
Name = 'Jakub'
Age = 28
KnowsPowerShell = $true
Languages = 'Czech', 'English'
ProgrammingLanguage =
[PSCustomObject]@{
Name = 'PowerShell'
Type = 'Scripting'
}
}
}
# get two objects that have the same data, but are different instances
Assert-Equivalent -Actual (Get-Object) -Expected (Get-Object) -Verbose
VERBOSE: $Expected has type System.Management.Automation.PSCustomObject, $Actual has type System.Management.Automation.PSCustomObject, they are both non-null.
VERBOSE: $Expected is an object of type System.Management.Automation.PSCustomObject, we will be comparing $Actual to objects.
VERBOSE: Comparing all (5) properties of $Expected to $Actual.
VERBOSE: Property 'Name was found on $Actual, comparing them for equivalence.
VERBOSE: (.Name) - $Expected has type string, $Actual has type string, they are both non-null.
VERBOSE: (.Name) - $Expected is a value (value type, string, single value array, or a scriptblock), we will be comparing $Actual to value types.
VERBOSE: (.Name) - Comparing values as string because $Expected has that type.
VERBOSE: (.Name) EQUIVALENCE - $Actual is equivalent to Jakub because it is Jakub, and Jakub coalesced to string is Jakub.
VERBOSE: EQUIVALENCE - Property 'Name is equivalent.
VERBOSE: Property 'Age was found on $Actual, comparing them for equivalence.
VERBOSE: (.Age) - $Expected has type int, $Actual has type int, they are both non-null.
VERBOSE: (.Age) - $Expected is a value (value type, string, single value array, or a scriptblock), we will be comparing $Actual to value types.
VERBOSE: (.Age) - Comparing values as int because $Expected has that type.
VERBOSE: (.Age) EQUIVALENCE - $Actual is equivalent to 28 because it is 28, and 28 coalesced to int is 28.
VERBOSE: EQUIVALENCE - Property 'Age is equivalent.
VERBOSE: Property 'KnowsPowerShell was found on $Actual, comparing them for equivalence.
VERBOSE: (.KnowsPowerShell) - $Expected has type bool, $Actual has type bool, they are both non-null.
VERBOSE: (.KnowsPowerShell) - $Expected is a value (value type, string, single value array, or a scriptblock), we will be comparing $Actual to value types.
VERBOSE: (.KnowsPowerShell) - Comparing values as bool because $Expected has that type.
VERBOSE: (.KnowsPowerShell) EQUIVALENCE - $Actual is equivalent to $true because it is $true, and $true coalesced to bool is $true.
VERBOSE: EQUIVALENCE - Property 'KnowsPowerShell is equivalent.
VERBOSE: Property 'Languages was found on $Actual, comparing them for equivalence.
VERBOSE: (.Languages) - $Expected has type System.Object[], $Actual has type System.Object[], they are both non-null.
VERBOSE: (.Languages) - $Expected is a collection, we will be comparing $Actual to collections.
VERBOSE: (.Languages) - Comparing items in collection, $Expected has lenght 2, $Actual has length 2.
VERBOSE: (.Languages) -
Searching for $Expected[0]:
VERBOSE: (.Languages) - Comparing $Actual[0] to $Expected[0] to see if they are equivalent.
VERBOSE: (.Languages) - $Expected has type string, $Actual has type string, they are both non-null.
VERBOSE: (.Languages) - $Expected is a value (value type, string, single value array, or a scriptblock), we will be comparing $Actual to value types.
VERBOSE: (.Languages) - Comparing values as string because $Expected has that type.
VERBOSE: (.Languages) EQUIVALENCE - $Actual is equivalent to Czech because it is Czech, and Czech coalesced to string is Czech.
VERBOSE: (.Languages) EQUIVALENCE - Found equivalent item for $Expected[0] at $Actual[0].
VERBOSE: (.Languages) -
Searching for $Expected[1]:
VERBOSE: (.Languages) - Skipping $Actual[0] because it is already taken.
VERBOSE: (.Languages) - Comparing $Actual[1] to $Expected[1] to see if they are equivalent.
VERBOSE: (.Languages) - $Expected has type string, $Actual has type string, they are both non-null.
VERBOSE: (.Languages) - $Expected is a value (value type, string, single value array, or a scriptblock), we will be comparing $Actual to value types.
VERBOSE: (.Languages) - Comparing values as string because $Expected has that type.
VERBOSE: (.Languages) EQUIVALENCE - $Actual is equivalent to English because it is English, and English coalesced to string is English.
VERBOSE: (.Languages) EQUIVALENCE - Found equivalent item for $Expected[1] at $Actual[1].
VERBOSE: (.Languages) EQUIVALENCE - $Actual and $Expected arrays are equivalent.
VERBOSE: EQUIVALENCE - Property 'Languages is equivalent.
VERBOSE: Property 'ProgrammingLanguage was found on $Actual, comparing them for equivalence.
VERBOSE: (.ProgrammingLanguage) - $Expected has type System.Management.Automation.PSCustomObject, $Actual has type System.Management.Automation.PSCustomObject, they are both non-null.
VERBOSE: (.ProgrammingLanguage) - $Expected is an object of type System.Management.Automation.PSCustomObject, we will be comparing $Actual to objects.
VERBOSE: (.ProgrammingLanguage) - Comparing all (2) properties of $Expected to $Actual.
VERBOSE: (.ProgrammingLanguage) - Property 'Name was found on $Actual, comparing them for equivalence.
VERBOSE: (.ProgrammingLanguage.Name) - $Expected has type string, $Actual has type string, they are both non-null.
VERBOSE: (.ProgrammingLanguage.Name) - $Expected is a value (value type, string, single value array, or a scriptblock), we will be comparing $Actual to value types.
VERBOSE: (.ProgrammingLanguage.Name) - Comparing values as string because $Expected has that type.
VERBOSE: (.ProgrammingLanguage.Name) EQUIVALENCE - $Actual is equivalent to PowerShell because it is PowerShell, and PowerShell coalesced to string is PowerShell.
VERBOSE: (.ProgrammingLanguage) EQUIVALENCE - Property 'Name is equivalent.
VERBOSE: (.ProgrammingLanguage) - Property 'Type was found on $Actual, comparing them for equivalence.
VERBOSE: (.ProgrammingLanguage.Type) - $Expected has type string, $Actual has type string, they are both non-null.
VERBOSE: (.ProgrammingLanguage.Type) - $Expected is a value (value type, string, single value array, or a scriptblock), we will be comparing $Actual to value types.
VERBOSE: (.ProgrammingLanguage.Type) - Comparing values as string because $Expected has that type.
VERBOSE: (.ProgrammingLanguage.Type) EQUIVALENCE - $Actual is equivalent to Scripting because it is Scripting, and Scripting coalesced to string is Scripting.
VERBOSE: (.ProgrammingLanguage) EQUIVALENCE - Property 'Type is equivalent.
VERBOSE: (.ProgrammingLanguage) EQUIVALENCE - $Actual has no extra properties that $Expected does not have.
VERBOSE: EQUIVALENCE - Property 'ProgrammingLanguage is equivalent.
VERBOSE: EQUIVALENCE - $Actual has no extra properties that $Expected does not have.
VERBOSE: EQUIVALENCE - $Actual and $Expected are equivalent.
(The output is still in progress, suggestions to make it better are welcome, but keep in mind that it needs to work for objects much bigger than this.)
Bug fixes:
- Fixes bug where equivalent collections with three or more same items were reported as different
- Fixes bug where the only diff the only