From 7c7e996be6ffe813f211d00a0597f4b5bca3fd56 Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Thu, 12 Nov 2015 19:23:24 +0000 Subject: [PATCH] Added Get-EventSubscriber pester test --- .../Get-EventSubscriber.Tests.ps1 | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/pester-tests/Get-EventSubscriber.Tests.ps1 diff --git a/src/pester-tests/Get-EventSubscriber.Tests.ps1 b/src/pester-tests/Get-EventSubscriber.Tests.ps1 new file mode 100644 index 0000000000..3b360fad53 --- /dev/null +++ b/src/pester-tests/Get-EventSubscriber.Tests.ps1 @@ -0,0 +1,30 @@ +Describe "Get-EventSubscriber" { + + 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).GetType() | Should Be 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 + + } + } +}