Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Move-PSKoanLibrary Function #364

Merged
merged 6 commits into from
Mar 2, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
✅ Refactor error command tests
vexx32 committed Mar 1, 2020
commit 5063477e26b32e2d12bfbbae75f3447d786b034e
34 changes: 30 additions & 4 deletions Tests/Functions/Private/New-PSKoanErrorRecord.Tests.ps1
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
Describe 'New-PSKoanErrorRecord' {

Context 'With Exception Object' {

BeforeAll {
$Output, $Parameters = InModuleScope 'PSKoans' {
$Params = @{
@@ -20,16 +21,29 @@ Describe 'New-PSKoanErrorRecord' {
$Output | Should -BeOfType System.Management.Automation.ErrorRecord
}

It 'creates output with properties matching the parameters supplied' {
It 'emits the same type of exception' {
$Output.Exception | Should -BeOfType $Parameters.Exception.GetType().FullName
}

It 'includes the input exception message' {
$Output.Exception.Message | Should -BeExactly $Parameters.Exception.Message
}

It 'emits the correct error ID with "PSKoans" prefix' {
$Output.FullyQualifiedErrorId | Should -BeExactly "PSKoans.$($Parameters.ErrorId)"
}

It 'assigns the requested error category' {
$Output.CategoryInfo.Category | Should -Be $Parameters.ErrorCategory
$Output.TargetObject | Should -BeNullOrEmpty
}

It 'assigns the target object' {
$Output.TargetObject | Should -Be $Params.TargetObject
}
}

Context 'With TypeName and Message' {

BeforeAll {
$Output, $Parameters = InModuleScope 'PSKoans' {
$Params = @{
@@ -48,12 +62,24 @@ Describe 'New-PSKoanErrorRecord' {
$Output | Should -BeOfType System.Management.Automation.ErrorRecord
}

It 'creates output with properties matching the parameters supplied' {
It 'creates the correct type of exception' {
$Output.Exception | Should -BeOfType $Parameters.ExceptionType
}

It 'applies the requested exception message' {
$Output.Exception.Message | Should -BeExactly $Parameters.ExceptionMessage
}

It 'emits the correct error ID with "PSKoans" prefix' {
$Output.FullyQualifiedErrorId | Should -BeExactly "PSKoans.$($Parameters.ErrorId)"
}

It 'assigns the requested error category' {
$Output.CategoryInfo.Category | Should -Be $Parameters.ErrorCategory
$Output.TargetObject | Should -BeNullOrEmpty
}

It 'assigns the target object' {
$Output.TargetObject | Should -Be $Params.TargetObject
}
}
}