Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
Get-EventLog.Tests.ps149 linesDownload Raw Back to Microsoft.PowerShell.Management
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {4 5    BeforeAll {6        $defaultParamValues = $PSDefaultParameterValues.Clone()7        $PSDefaultParameterValues["it:skip"] = !$IsWindows -or $IsCoreCLR8    }9 10    AfterAll {11        $global:PSDefaultParameterValues = $defaultParamValues12    }13 14    #CmdLets are not yet implemented, so these cases are -Pending:($true) for now...15    It "should return an array of eventlogs objects when called with -AsString parameter" -Pending:($true) {16      { $result=Get-EventLog -AsString -ErrorAction Stop } | Should -Not -Throw17      $result                                              | Should -Not -BeNullOrEmpty18      ,$result                                             | Should -BeOfType System.Array19      $result                                              | Should -BeExactly "Application"20      $result.Count                                        | Should -BeGreaterThan 321    }22    It "should return a list of eventlog objects when called with -List parameter" -Pending:($true) {23      { $result=Get-EventLog -List -ErrorAction Stop }      | Should -Not -Throw24      $result                                               | Should -Not -BeNullOrEmpty25      ,$result                                              | Should -BeOfType System.Array26      {$logs=$result | Select-Object -ExpandProperty Log}   | Should -Not -Throw27      $logs                                                 | Should -BeExactly "System"28      $logs.Count                                           | Should -BeGreaterThan 329    }30    It "should be able to Get-EventLog -LogName Application -Newest 100" -Pending:($true) {31      { $result=Get-EventLog -LogName Application -Newest 100 -ErrorAction Stop } | Should -Not -Throw32      $result                                                                     | Should -Not -BeNullOrEmpty33      $result.Length                                                              | Should -BeLessThan 10034      $result[0]                                                                  | Should -BeOfType EventLogEntry35    }36    It "should throw 'AmbiguousParameterSetException' when called with both -LogName and -List parameters" -Pending:($true) {37      { Get-EventLog -LogName System -List -ErrorAction Stop } | Should -Throw -ErrorId "AmbiguousParameterSet,Microsoft.PowerShell.Commands.GetEventLogCommand"38    }39    It "should be able to Get-EventLog -LogName * with multiple matches" -Pending:($true) {40      { $result=Get-EventLog -LogName *  -ErrorAction Stop }  | Should -Not -Throw41      $result                                                 | Should -Not -BeNullOrEmpty42      $result                                                 | Should -BeExactly "Security"43      $result.Count                                           | Should -BeGreaterThan 344    }45    It "should throw 'InvalidOperationException' when asked to get a log that does not exist" -Pending:($true) {46      { Get-EventLog  -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"47    }48}49