forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-EventSubscriber.Tests.ps1
More file actions
30 lines (24 loc) · 1.44 KB
/
Copy pathGet-EventSubscriber.Tests.ps1
File metadata and controls
30 lines (24 loc) · 1.44 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
Describe "Get-EventSubscriber" -Tags "CI" {
AfterEach {
Unregister-Event -SourceIdentifier PesterTestRegister -ErrorAction SilentlyContinue
}
Context "Check return type of Get-EventSubscriber" {
It "Should return System.Management.Automation.PSEventSubscriber as return type of New-Event" {
$pesterobject = (New-Object System.Collections.ObjectModel.ObservableCollection[object])
Register-ObjectEvent -InputObject $pesterobject -EventName CollectionChanged -SourceIdentifier PesterTestRegister
Get-EventSubscriber | Should BeOfType System.Management.Automation.PSEventSubscriber
}
}
Context "Check Get-EventSubscriber can validly register events"{
It "Should return source identifier of PesterTimer " {
$pesterobject = (New-Object System.Collections.ObjectModel.ObservableCollection[object])
Register-ObjectEvent -InputObject $pesterobject -EventName CollectionChanged -SourceIdentifier PesterTestRegister
(Get-EventSubscriber -SourceIdentifier PesterTestRegister).SourceIdentifier | Should Be "PesterTestRegister"
}
It "Should return an integer greater than 0 for the SubscriptionId" {
$pesterobject = (New-Object System.Collections.ObjectModel.ObservableCollection[object])
Register-ObjectEvent -InputObject $pesterobject -EventName CollectionChanged -SourceIdentifier PesterTestRegister
(Get-EventSubscriber -SourceIdentifier PesterTestRegister).SubscriptionId | Should BeGreaterThan 0
}
}
}