From 777ba09bce5885d5ea6ee4a488d2ca79dd936b7e Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Thu, 30 Jun 2016 16:32:59 -0700 Subject: [PATCH] Add a simple test for Get-WinEvent on windows (Core + Full) --- test/fullclr/PowerShellGithubDev.Tests.ps1 | 14 ++++++++++++++ .../Get-WinEvent.Tests.ps1 | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 diff --git a/test/fullclr/PowerShellGithubDev.Tests.ps1 b/test/fullclr/PowerShellGithubDev.Tests.ps1 index 9e36017357..944ee69bcf 100644 --- a/test/fullclr/PowerShellGithubDev.Tests.ps1 +++ b/test/fullclr/PowerShellGithubDev.Tests.ps1 @@ -122,6 +122,20 @@ try Remove-Module -ErrorAction SilentlyContinue CimCmdlets } } + + It 'loads Microsoft.PowerShell.Diagnostics' { + try + { + Import-Module Microsoft.PowerShell.Diagnostics -ErrorAction Stop + Get-WinEvent -LogName System -MaxEvents 1 | Should Not Be $null + [Microsoft.PowerShell.Commands.GetWinEventCommand].Assembly.Location | Should Be ( + Join-Path $env:DEVPATH Microsoft.PowerShell.Commands.Diagnostics.dll) + } + finally + { + Remove-Module -ErrorAction SilentlyContinue Microsoft.PowerShell.Diagnostics + } + } } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 new file mode 100644 index 0000000000..fc438e94b6 --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Diagnostics/Get-WinEvent.Tests.ps1 @@ -0,0 +1,7 @@ +Describe 'Get-WinEvent' { + + # Get-WinEvent works only on windows + It 'can query a System log' -Skip:(-not $IsWindows) { + Get-WinEvent -LogName System -MaxEvents 1 | Should Not Be $null + } +}