From 3d1d89643bae536ed10b3ad85e6b1cb634042674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Sun, 7 Apr 2024 23:16:23 +0200 Subject: [PATCH] Add Should-* aliases --- src/Module.ps1 | 55 +++++++++++++++++++++++++++++++++++++++++++++++-- src/Pester.psd1 | 27 +++++++++++++++++++++++- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/Module.ps1 b/src/Module.ps1 index c0cf869c0..ee55b8b44 100644 --- a/src/Module.ps1 +++ b/src/Module.ps1 @@ -5,8 +5,33 @@ $script:SafeCommands['Get-MockDynamicParameter'] = $ExecutionContext.SessionStat $script:SafeCommands['Write-PesterDebugMessage'] = $ExecutionContext.SessionState.InvokeCommand.GetCommand('Write-PesterDebugMessage', 'function') $script:SafeCommands['Set-DynamicParameterVariable'] = $ExecutionContext.SessionState.InvokeCommand.GetCommand('Set-DynamicParameterVariable', 'function') -& $SafeCommands['Set-Alias'] 'Add-AssertionOperator' 'Add-ShouldOperator' -& $SafeCommands['Set-Alias'] 'Get-AssertionOperator' 'Get-ShouldOperator' +& $SafeCommands['Set-Alias'] 'Add-AssertionOperator' 'Add-ShouldOperator' +& $SafeCommands['Set-Alias'] 'Get-AssertionOperator' 'Get-ShouldOperator' + +& $SafeCommands['Set-Alias'] 'Should-BeFalse' 'Assert-False' +& $SafeCommands['Set-Alias'] 'Should-BeTrue' 'Assert-True' +& $SafeCommands['Set-Alias'] 'Should-All' 'Assert-All' +& $SafeCommands['Set-Alias'] 'Should-Any' 'Assert-Any' +& $SafeCommands['Set-Alias'] 'Should-Contain' 'Assert-Contain' +& $SafeCommands['Set-Alias'] 'Should-NotContain' 'Assert-NotContain' +& $SafeCommands['Set-Alias'] 'Should-BeEquivalent' 'Assert-Equivalent' +& $SafeCommands['Set-Alias'] 'Should-Throw' 'Assert-Throw' +& $SafeCommands['Set-Alias'] 'Should-BeEqual' 'Assert-Equal' +& $SafeCommands['Set-Alias'] 'Should-BeGreaterThan' 'Assert-GreaterThan' +& $SafeCommands['Set-Alias'] 'Should-BeGreaterThanOrEqual' 'Assert-GreaterThanOrEqual' +& $SafeCommands['Set-Alias'] 'Should-BeLessThan' 'Assert-LessThan' +& $SafeCommands['Set-Alias'] 'Shoulde-BeLessThanOrEqual' 'Assert-LessThanOrEqual' +& $SafeCommands['Set-Alias'] 'Should-NotBeEqual' 'Assert-NotEqual' +& $SafeCommands['Set-Alias'] 'Should-NotBeNull' 'Assert-NotNull' +& $SafeCommands['Set-Alias'] 'Should-NotBeSame' 'Assert-NotSame' +& $SafeCommands['Set-Alias'] 'Should-NotBeType' 'Assert-NotType' +& $SafeCommands['Set-Alias'] 'Should-BeNull' 'Assert-Null' +& $SafeCommands['Set-Alias'] 'Should-BeSame' 'Assert-Same' +& $SafeCommands['Set-Alias'] 'Should-BeType' 'Assert-Type' +& $SafeCommands['Set-Alias'] 'Should-BeLike' 'Assert-Like' +& $SafeCommands['Set-Alias'] 'Should-NotBeLike' 'Assert-NotLike' + + & $SafeCommands['Update-TypeData'] -TypeName PesterConfiguration -TypeConverter 'PesterConfigurationDeserializer' -SerializationDepth 5 -Force & $SafeCommands['Update-TypeData'] -TypeName 'Deserialized.PesterConfiguration' -TargetTypeForDeserialization PesterConfiguration -Force @@ -82,4 +107,30 @@ $script:SafeCommands['Set-DynamicParameterVariable'] = $ExecutionContext.Session ) -Alias @( 'Add-AssertionOperator' 'Get-AssertionOperator' + + # assert + 'Should-BeFalse' + 'Should-BeTrue' + 'Should-All' + 'Should-Any' + 'Should-Contain' + 'Should-NotContain' + 'Should-BeEquivalent' + 'Should-Throw' + 'Should-BeEqual' + 'Should-BeGreaterThan' + 'Should-BeGreaterThanOrEqual' + 'Should-BeLessThan' + 'Shoulde-BeLessThanOrEqual' + 'Should-NotBeEqual' + 'Should-NotBeNull' + 'Should-NotBeSame' + 'Should-NotBeType' + 'Should-BeNull' + 'Should-BeSame' + 'Should-BeType' + 'Should-BeLike' + 'Should-NotBeLike' + 'Should-StringBeEqual' + 'Should-StringNotBeEqual' ) diff --git a/src/Pester.psd1 b/src/Pester.psd1 index 4a42f5149..2e84e6a46 100644 --- a/src/Pester.psd1 +++ b/src/Pester.psd1 @@ -92,7 +92,6 @@ 'Assert-StringEqual' 'Assert-StringNotEqual' - # legacy 'Assert-VerifiableMock' 'Assert-MockCalled' @@ -112,6 +111,32 @@ AliasesToExport = @( 'Add-AssertionOperator' 'Get-AssertionOperator' + + # assert + 'Should-BeFalse' + 'Should-BeTrue' + 'Should-All' + 'Should-Any' + 'Should-Contain' + 'Should-NotContain' + 'Should-BeEquivalent' + 'Should-Throw' + 'Should-BeEqual' + 'Should-BeGreaterThan' + 'Should-BeGreaterThanOrEqual' + 'Should-BeLessThan' + 'Shoulde-BeLessThanOrEqual' + 'Should-NotBeEqual' + 'Should-NotBeNull' + 'Should-NotBeSame' + 'Should-NotBeType' + 'Should-BeNull' + 'Should-BeSame' + 'Should-BeType' + 'Should-BeLike' + 'Should-NotBeLike' + 'Should-StringBeEqual' + 'Should-StringNotBeEqual' )