-
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit with the basics working
- Loading branch information
0 parents
commit a1d6a0e
Showing
8 changed files
with
107 additions
and
0 deletions.
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,27 @@ | ||
$pwd = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
. "$pwd\Add-Numbers.ps1" | ||
. "$pwd\..\..\Source\Pester.ps1" | ||
|
||
Describe "Add-Numbers" { | ||
|
||
It "adds positive numbers" { | ||
$sum = Add-Numbers 2 3 | ||
$sum.should.be(4) | ||
} | ||
|
||
It "adds negative numbers" { | ||
$sum = Add-Numbers (-2) (-2) | ||
$sum.should.be((-4)) | ||
} | ||
|
||
It "adds one negative number to positive number" { | ||
$sum = Add-Numbers (-2) 2 | ||
$sum.should.be(0) | ||
} | ||
|
||
It "concatenates strings if given strings" { | ||
$sum = Add-Numbers two three | ||
$sum.should.be("twothree") | ||
} | ||
|
||
} |
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,3 @@ | ||
function Add-Numbers($a, $b) { | ||
return $a + $b | ||
} |
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 @@ | ||
Pester | ||
====== | ||
|
||
Objective | ||
--------- | ||
|
||
I wanted to make a convention based Powershell Unit testing framework that didn't require the following: | ||
|
||
* Installer of any sort | ||
* Changing a users Profile script | ||
|
||
The things I wanted it do do is: | ||
|
||
* Find all tests by some sort of convention | ||
* Emulate RSpec assertions and fixture setup | ||
* Create NUnit XML reports |
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,4 @@ | ||
function Describe($name, [ScriptBlock] $fixture) { | ||
Write-Host -fore yellow Describing $name | ||
& $fixture | ||
} |
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,13 @@ | ||
function It($name, [ScriptBlock] $test) | ||
{ | ||
Write-Host -fore DarkCyan $name -NoNewLine | ||
|
||
$test_result = & $test | ||
|
||
if ($test_result) { | ||
Write-Host -ForegroundColor green " Success" | ||
} else { | ||
Write-Host -ForegroundColor red " Failure`n$($test.ToString())" | ||
} | ||
} | ||
|
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Types> | ||
<Type> | ||
<Name>System.Object</Name> | ||
<Members> | ||
<ScriptProperty> | ||
<Name>should</Name> | ||
<GetScriptBlock> | ||
$value = $this | ||
$object = New-Object Object | | ||
Add-Member ScriptMethod be { | ||
param($expected) | ||
return ($expected -eq $this.actual) | ||
} -PassThru | | ||
Add-Member NoteProperty -Name actual -Value $null -PassThru | | ||
Add-Member ScriptProperty -Name ThisValue -Value { $this.actual } ` | ||
{ | ||
param($newactual) | ||
$this.actual = $newactual | ||
} -PassThru | ||
$object.ThisValue = $value | ||
|
||
return $object | ||
</GetScriptBlock> | ||
</ScriptProperty> | ||
</Members> | ||
</Type> | ||
</Types> |
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,12 @@ | ||
param($relative_path = ".") | ||
|
||
$script_dir = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
Update-TypeData -pre "$script_dir\ObjectAdaptations\types.ps1xml" -ErrorAction SilentlyContinue | ||
|
||
$fixtures_path = Resolve-Path $relative_path | ||
Write-Host Executing all tests in $fixtures_path | ||
|
||
Get-ChildItem $fixtures_path -Recurse | | ||
? { $_.Name -match ".Tests." } | | ||
% { & $_.PSPath } | ||
|
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,4 @@ | ||
$pwd = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
|
||
Resolve-Path $pwd\Functions\*.ps1 | % { . $_.ProviderPath } | ||
|