Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Event.Tests.ps1
T

35 lines
1.0 KiB
PowerShell
Raw Normal View History

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
2016-07-25 14:01:41 -07:00
Describe "Get-Event" -Tags "CI" {
2015-11-19 06:20:50 +00:00
BeforeEach {
( New-Event -SourceIdentifier PesterTestEvent -Sender Windows.timer -MessageData "PesterTestMessage" )
}
2015-11-19 06:20:50 +00:00
AfterEach {
( Remove-Event -SourceIdentifier PesterTestEvent -ErrorAction SilentlyContinue )
2015-11-19 06:20:50 +00:00
}
2015-11-19 06:20:50 +00:00
Context "Check return type of Get-Event" {
It "Should return PSEventArgs as return type of Get-Event" {
Get-Event -SourceIdentifier PesterTestEvent | Should -BeOfType System.Management.Automation.PSEventArgs
2015-11-19 06:20:50 +00:00
}
}
Context "Validate Get-Event can retrieve event" {
It "Should return at least 1 event" {
{ (Get-Event).Count | Should -BeGreaterThan 0 }
2015-11-19 06:20:50 +00:00
}
2015-11-19 06:20:50 +00:00
It "Should return PesterTestMessage as the MessageData" {
{ (Get-Event -SourceIdentifier PesterTimer).MessageData | Should -BeExactly "PesterTestMessage" }
2015-11-19 06:20:50 +00:00
}
It "Should return Sender as Windows.timer" {
{ (Get-Event -SourceIdentifier PesterTimer).Sender | Should -Be Windows.timer }
2015-11-19 06:20:50 +00:00
}
2015-11-19 06:20:50 +00:00
}
}