@@ -13,20 +13,22 @@ Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') { |
13 | 13 |
|
14 | 14 | It "should be able to Clear-EventLog" -Pending:($True) { |
15 | 15 | Remove-EventLog -LogName TestLog -ea Ignore |
16 | | - {New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop} | Should -Not -Throw |
17 | | - {Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Not -Throw |
18 | | - {$result=Get-EventLog -LogName TestLog} | Should -Not -Throw |
19 | | - ($result.Count) | Should -Be 1 |
20 | | - {Clear-EventLog -LogName TestLog} | Should -Not -Throw |
21 | | - $result=Get-EventLog -LogName TestLog -ea Ignore |
22 | | - ($result.Count) | Should -Be 0 |
23 | | - {Remove-EventLog -LogName TestLog -ErrorAction Stop} | Should -Not -Throw |
24 | | - } |
25 | | - It "should throw 'The Log name 'MissingTestLog' does not exist' when asked to clear a log that does not exist" -Pending:($True) { |
26 | | - Remove-EventLog -LogName MissingTestLog -ea Ignore |
27 | | - { Clear-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.ClearEventLogCommand" |
| 16 | + { New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop } | Should -Not -Throw |
| 17 | + { Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Not -Throw |
| 18 | + { Get-EventLog -LogName TestLog } | Should -Not -Throw |
| 19 | + $result = Get-EventLog -LogName TestLog |
| 20 | + $result.Count | Should -Be 1 |
| 21 | + { Clear-EventLog -LogName TestLog } | Should -Not -Throw |
| 22 | + $result = Get-EventLog -LogName TestLog -ErrorAction Ignore |
| 23 | + $result.Count | Should -Be 0 |
| 24 | + { Remove-EventLog -LogName TestLog -ErrorAction Stop } | Should -Not -Throw |
28 | 25 | } |
| 26 | + |
29 | 27 | It "should throw 'System.InvalidOperationException' when asked to clear a log that does not exist" -Pending:($True) { |
| 28 | + { Clear-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ExceptionType "System.InvalidOperationException" |
| 29 | + } |
| 30 | + |
| 31 | + It "should throw 'Microsoft.PowerShell.Commands.ClearEventLogCommand' ErrorId when asked to clear a log that does not exist" -Pending:($True) { |
30 | 32 | { Clear-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.ClearEventLogCommand" |
31 | 33 | } |
32 | 34 | } |