Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
starting mocking...so exciting!!
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") | ||
. "$here\$sut" | ||
|
||
function FunctionUnderTest { | ||
return "I am a real world test" | ||
} | ||
|
||
Describe "When calling Mock" { | ||
Mock FunctionUnderTest {return} | ||
|
||
It "Should rename function under test" { | ||
$rename = gci function:PesterIsMocking_FunctionUnderTest | ||
$rename.Count.should.be(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function Mock ([string]$function, [ScriptBlock]$mockWith, [switch]$verifiable, [HashTable]$parameterFilters = @{}) | ||
{ | ||
# If verifiable, add to a verifiable hashtable | ||
# Rename existing function | ||
# Create New Function to invoke Script Block | ||
# Mocked function should redirect to real function if param filters are not met | ||
# param filters are met, mark in the verifiable table | ||
} | ||
|
||
function Assert-VerifiableMocks { | ||
# Check that the Verifiables have all been called | ||
# if not, throw | ||
} | ||
|
||
function Clear-Mocks { | ||
# Called at the end of Describe | ||
# Clears the Verifiable table | ||
# Renames all renamed mocks back to original names | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters