-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIStack.Tests.ps1
More file actions
51 lines (44 loc) · 1.13 KB
/
IStack.Tests.ps1
File metadata and controls
51 lines (44 loc) · 1.13 KB
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
#Requires -Module Example.Specification
Param(
[Example.Specification.IStack[string]] $Instance
)
Describe "The IStack" {
Context "while empty" {
It "shall report empty" {
$Instance.Count | Should Be 0
}
}
It "shall accept items" {
$Instance.Push('item1')
$Instance.Peek() | Should Be 'item1'
}
Context "when peeking at the most recent item" {
It "shall retain all items" {
$before = $Instance.Count
$Instance.Peek() | Should Be 'item1'
$Instance.Count | Should Be $before
}
}
It "shall hold multiple items" {
$Instance.Peek() | Should Be 'item1'
$Instance.Push('item2')
$Instance.Peek() | Should Be 'item2'
}
Context "while holds items" {
It "shall report how many" {
$Instance.Count | Should Be 2
}
}
Context "when removing items" {
It "shall remove the most recently added item" {
$Instance.Pop() | Should Be 'item2'
$Instance.Count | Should Be 1
$Instance.Peek() | Should Be 'item1'
}
It "shall not remove past empty" {
$Instance.Pop() | Out-Null
$Instance.Count | Should Be 0
{ $Instance.Pop() } | Should Throw
}
}
}