Examples/Validator/Validator.Tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$scriptRoot = Split-Path $MyInvocation.MyCommand.Path
. $scriptRoot\Validator.ps1 -Verbose

Describe "Testing a validator" {

    It "calls MyValidator" {
        Mock MyValidator -MockWith { return $true }
        Invoke-SomethingThatUsesMyValidator "test"
        $was_called_once = 1
        Assert-MockCalled MyValidator $was_called_once
    }

}

Describe "MyValidator" {

    It "passes things that start with the letter S" {
        $result = MyValidator "summer"
        $result | Should Be $true
    }

    It "does not pass a param that does not start with S" {
        $result = MyValidator "bummer"
        $result | Should Be $false
    }
}