Skip to content

Commit

Permalink
Move Into Context Block as Per Feedback from @fflaten
Browse files Browse the repository at this point in the history
  • Loading branch information
aolszowka committed Apr 29, 2021
1 parent 9d9d4e2 commit c866694
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tst/functions/New-MockObject.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ describe 'New-MockObject' {
$type = 'Microsoft.PowerShell.Commands.Language'
New-MockObject -Type $type | should -beoftype $type
}
}

Describe 'New-MockObject-With-Properties' {
# System.Diagnostics.Process.Id is normally read only, using the
# Properties switch in New-MockObject should allow us to mock these.
it 'Fails with just a normal mock' {
$mockedProcess = New-MockObject -Type 'System.Diagnostics.Process'
Context 'Modifying readonly-properties' {
# System.Diagnostics.Process.Id is normally read only, using the
# Properties switch in New-MockObject should allow us to mock these.
it 'Fails with just a normal mock' {
$mockedProcess = New-MockObject -Type 'System.Diagnostics.Process'

{ $mockedProcess.Id = 123 } | Should -Throw
}
{ $mockedProcess.Id = 123 } | Should -Throw
}

it 'Works when you mock the property' {
$mockedProcess = New-MockObject -Type 'System.Diagnostics.Process' -Properties @{Id = 123 }
it 'Works when you mock the property' {
$mockedProcess = New-MockObject -Type 'System.Diagnostics.Process' -Properties @{Id = 123 }

$mockedProcess.Id | Should -Be 123
}
$mockedProcess.Id | Should -Be 123
}

it 'Should preserve types' {
$mockedProcess = New-MockObject -Type 'System.Diagnostics.Process' -Properties @{Id = 123 }
$mockedProcess.Id | Should -BeOfType [int]
it 'Should preserve types' {
$mockedProcess = New-MockObject -Type 'System.Diagnostics.Process' -Properties @{Id = 123 }
$mockedProcess.Id | Should -BeOfType [int]
}
}
}

0 comments on commit c866694

Please sign in to comment.