You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$err.Exception.Message| Verify-Equal "Expected command Invoke-DummyFunction to have a parameter ParamWithNotNullOrEmptyValidation, which is mandatory, of type [System.TimeSpan], the default value to be 'wrong value' and has ArgumentCompletion, because of reasons, but it wasn't mandatory, it was of type [System.DateTime], the default value was '(Get-Date)' and has no ArgumentCompletion."
324
326
}
325
327
}
328
+
329
+
Context 'Using InParameterSet' {
330
+
It "passes if parameter <ParameterName> exist in parameter set <ParameterSetName>"-TestCases @(
$err= { Get-Command'Invoke-DummyFunction'| Should -HaveParameter $ParameterName-InParameterSet $ParameterSetName } | Verify-AssertionFailed
348
+
$err.Exception.Message| Verify-Equal "Expected command Invoke-DummyFunction to have a parameter $ParameterName in parameter set $ParameterSetName, but the parameter is missing."
349
+
}
350
+
351
+
It 'fails if parameter <ParameterName> exists in parameter set <ParameterSetName> but is not mandatory'-TestCases @(
$err= { Get-Command'Invoke-DummyFunction'| Should -HaveParameter $ParameterName-InParameterSet $ParameterSetName-Mandatory } | Verify-AssertionFailed
355
+
$err.Exception.Message| Verify-Equal "Expected command Invoke-DummyFunction to have a parameter $ParameterName in parameter set $ParameterSetName, which is mandatory, but it wasn't mandatory."
356
+
}
357
+
358
+
# -InParameterSet only affects if parameter exist and -Mandatory atm. Only appends a filter in the error for the remaining options
359
+
}
326
360
}
327
361
328
362
Describe "Should -Not -HaveParameter" {
@@ -492,6 +526,25 @@ InPesterModuleScope {
492
526
$err.Exception.Message| Verify-Equal "Expected command Invoke-DummyFunction to not have a parameter $ParameterName, not of type [$ExpectedType], the default value not to be '$ExpectedValue' and has ArgumentCompletion, because of reasons, but it was of type [$ExpectedType], the default value was '$ExpectedValue' and has ArgumentCompletion."
493
527
}
494
528
}
529
+
530
+
Context 'Using InParameterSet' {
531
+
It 'passes if parameter <ParameterName> does not exist at all or not in parameter set <ParameterSetName>'-TestCases @(
$err= { Get-Command'Invoke-DummyFunction'| Should -Not-HaveParameter $ParameterName-InParameterSet $ParameterSetName } | Verify-AssertionFailed
543
+
$err.Exception.Message| Verify-Equal "Expected command Invoke-DummyFunction to not have a parameter $ParameterName in parameter set $ParameterSetName, but the parameter exists."
544
+
}
545
+
546
+
# -Not -HaveParameter only supports parameter existing atm. Extend when not mandatory etc is possible.
0 commit comments