Open michaeltlombardi opened 7 years ago
I recently encountered a test where it would have been helpful to have a bool[]
type. See #100, the two DVS tests are a result of what direction I ended up taking.
Without ever testing it, I see no reason bool[]
doesn't work, if you want to investigate updating #100. Perfectly illustrating @michaeltlombardi's point, haha
I think as long as you can run ($Actual -as $Type) and it works than that type will work for that test. I have been able to test with pscustomobject, array, hastable, object, etc.
Edit: Actually, you can't use pscustomobject because Compare-Object
does not know what to compare unless you use -Property and specify the property to check. I need to double check, but i think (hope?) the others should work.
i was working on porting over the VM boot delay test. When you run this command:
(Get-VM $VMName).ExtensionData.Config.BootOptions.BootDelay.GetType()
It shows that it is a 'Int64'. The config file doesnt seem to be able to delineate between a int32 and a int64, meaning only $Type = 'int'
will work. $Type = 'long'
does not work.
What I had to do was type cast my $Desired so it stored it as an 'int'
We probably need a concept doc around this problem as discovered by @Midacts - test writers need a way to figure out what types they can/can't use and considerations to keep in mind for this.
Currently, only three types are documented in the tests/code for types consumable by json: bool, string, and int.
Expected Behavior
The available types should support arrays of string and int and perhaps other types as well.
Current Behavior
In a test you can specify
string[]
as a type but this is undocumented even though it works.Possible Solution
Decide on which types are acceptable and document them; at least document arrays.
Context
This would enable people to write better/more specific tests, especially in cases where the type should be an array of strings. This functionality already exists, it's just undocumented and people tend to assume that only documented things are possible.
Your Environment
1.0.1
10.0.14393
5.1.14393.693