Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use PowerShell syntax highlighting in the readme file.

  • Loading branch information...
commit 22157987dde4e87550d776a6edb3df572f6a6dd8 1 parent d218c19
@ming13 ming13 authored
Showing with 41 additions and 37 deletions.
  1. +41 −37 README.md
View
78 README.md
@@ -10,46 +10,50 @@ A Pester Test
-------------
BuildChanges.ps1
- function BuildIfChanged {
- $thisVersion=Get-Version
- $nextVersion=Get-NextVersion
- if($thisVersion -ne $nextVersion) {Build $nextVersion}
- return $nextVersion
- }
+```powershell
+function BuildIfChanged {
+ $thisVersion=Get-Version
+ $nextVersion=Get-NextVersion
+ if($thisVersion -ne $nextVersion) {Build $nextVersion}
+ return $nextVersion
+}
+```
BuildChanges.Tests.ps1
- $here = Split-Path -Parent $MyInvocation.MyCommand.Path
- $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
- . "$here\$sut"
-
- Describe "BuildIfChanged" {
- Context "When there are Changes" {
- Mock Get-Version {return 1.1}
- Mock Get-NextVersion {return 1.2}
- Mock Build {} -Verifiable -ParameterFilter {$version -eq 1.2}
-
- $result = BuildIfChanged
-
- It "Builds the next version" {
- Assert-VerifiableMocks
- }
- It "returns the next version number" {
- $result.Should.Be(1.2)
- }
- }
- Context "When there are no Changes" {
- Mock Get-Version -MockWith {return 1.1}
- Mock Get-NextVersion -MockWith {return 1.1}
- Mock Build {}
-
- $result = BuildIfChanged
-
- It "Should not build the next version" {
- Assert-MockCalled Build -Times 0 -ParameterFilter{$version -eq 1.1}
- }
- }
+```powershell
+$here = Split-Path -Parent $MyInvocation.MyCommand.Path
+$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
+. "$here\$sut"
+
+Describe "BuildIfChanged" {
+ Context "When there are Changes" {
+ Mock Get-Version {return 1.1}
+ Mock Get-NextVersion {return 1.2}
+ Mock Build {} -Verifiable -ParameterFilter {$version -eq 1.2}
+
+ $result = BuildIfChanged
+
+ It "Builds the next version" {
+ Assert-VerifiableMocks
+ }
+ It "returns the next version number" {
+ $result.Should.Be(1.2)
+ }
}
+ Context "When there are no Changes" {
+ Mock Get-Version -MockWith {return 1.1}
+ Mock Get-NextVersion -MockWith {return 1.1}
+ Mock Build {}
+
+ $result = BuildIfChanged
+
+ It "Should not build the next version" {
+ Assert-MockCalled Build -Times 0 -ParameterFilter{$version -eq 1.1}
+ }
+ }
+}
+```
Running Tests
-------------
@@ -75,4 +79,4 @@ Some further reading and resources:
* [pester-bdd-for-the-system-administrator](http://scottmuc.com/blog/development/pester-bdd-for-the-system-administrator/)
* [The Wiki](https://github.com/pester/Pester/wiki)
* [Google Discussion Group](https://groups.google.com/forum/?fromgroups#!forum/pester)
-* `C:\PS> Import-Module ./pester.psm1; Get-Help about_pester`
+* `C:\PS> Import-Module ./pester.psm1; Get-Help about_pester`
Please sign in to comment.
Something went wrong with that request. Please try again.