forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-EventLog.Tests.ps1
More file actions
48 lines (45 loc) · 2.89 KB
/
Copy pathGet-EventLog.Tests.ps1
File metadata and controls
48 lines (45 loc) · 2.89 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
Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {
$defaultParamValues = $PSdefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = !$IsWindows -or $IsCoreCLR
}
AfterAll {
$global:PSDefaultParameterValues = $defaultParamValues
}
#CmdLets are not yet implemented, so these cases are -Pending:($True) for now...
It "should return an array of eventlogs objects when called with -AsString parameter" -Pending:($True) {
{$result=Get-EventLog -AsString -ea stop} | Should Not Throw
$result | Should Not BeNullOrEmpty
,$result | Should BeOfType "System.Array"
$result -eq "Application" | Should Be "Application"
$result.Count -ge 3 | Should Be $true
}
It "should return a list of eventlog objects when called with -List parameter" -Pending:($True) {
{$result=Get-EventLog -List -ea stop} | Should Not Throw
$result | Should Not BeNullOrEmpty
,$result | Should BeOfType "System.Array"
{$logs=$result | Select-Object -ExpandProperty Log} | Should Not Throw
$logs -eq "System" | Should Be "System"
$logs.Count -ge 3 | Should Be $true
}
It "should be able to Get-EventLog -LogName Application -Newest 100" -Pending:($True) {
{$result=get-eventlog -LogName Application -Newest 100 -ea stop} | Should Not Throw
$result | Should Not BeNullOrEmpty
$result.Length -le 100 | Should Be $true
$result[0] | Should BeOfType "EventLogEntry"
}
It "should throw 'AmbiguousParameterSetException' when called with both -LogName and -List parameters" -Pending:($True) {
try {Get-EventLog -LogName System -List -ea stop; Throw "Previous statement unexpectedly succeeded..."
} catch {echo $_.FullyQualifiedErrorId | Should Be "AmbiguousParameterSet,Microsoft.PowerShell.Commands.GetEventLogCommand"}
}
It "should be able to Get-EventLog -LogName * with multiple matches" -Pending:($True) {
{$result=get-eventlog -LogName * -ea stop} | Should Not Throw
$result | Should Not BeNullOrEmpty
$result -eq "Security" | Should Be "Security"
$result.Count -ge 3 | Should Be $true
}
It "should throw 'InvalidOperationException' when asked to get a log that does not exist" -Pending:($True) {
try {Get-EventLog -LogName MissingTestLog -ea stop; Throw "Previous statement unexpectedly succeeded..."
} catch {echo $_.FullyQualifiedErrorId | Should Be "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"}
}
}