forked from pester/Pester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ps1xml
58 lines (55 loc) · 3 KB
/
types.ps1xml
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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)
if ($expected -ne $this.actual) {throw New-Object PesterFailure($expected,$this.actual)}
} -PassThru |
Add-Member ScriptMethod not_be {
param($expected)
if ($expected -eq $this.actual) {throw New-Object PesterFailure($expected,$this.actual)}
} -PassThru |
Add-Member ScriptMethod have_count_of {
param($expected_count)
$count = 0
$this.actual | % { $count += 1 }
if ($expected_count -ne $count) { throw New-Object PesterFailure($expected_count,$count)}
} -PassThru |
Add-Member ScriptMethod exist {
if (-not (Test-Path $this.actual)) { throw New-Object PesterFailure("$($this.actual) should exist","$($this.actual) not found")}
} -PassThru |
Add-Member ScriptMethod not_exist {
if (Test-Path $this.actual) { throw New-Object PesterFailure("$($this.actual) should not exist","$($this.actual) exists")}
} -PassThru |
Add-Member ScriptMethod match {
param($expected_match)
$matches = ($this.actual) |? { $_ -match $expected_match }
if (-not $matches) { throw New-Object PesterFailure("$expected_match should match $($this.actual)",
"$expected_match did not match $($this.actual)") }
} -PassThru |
Add-Member ScriptMethod be_like {
param($expected_like)
$matches = ($this.actual) |? { $_ -like $expected_like }
if (-not $matches) { throw New-Object PesterFailure("$expected_like should be like $($this.actual)",
"$expected_like was not like $($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>