mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/ClearEventLogDRT.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/CombinePathCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/ContentCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/ConvertPathCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/DebugProcessDRT.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/EventlogCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/GetEventLogDRTTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/GetHotFixDRTTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/GetProcessDRTTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/GetProviderCommandTest.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/GetServiceV2DRT.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/GetWMIObjectTest.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/InvokeWMIMethodTest.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/LimitEventLogDRT.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/NavigationTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/NewEventLogDRT.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/ParsePathCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/PingComputerDRT.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/PingPathCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/ProcessCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/ProcessTaskTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/PropertyCommandTests.cs https://github.com/PowerShell/psl-monad/monad/tests/monad/DRT/commands/management/UnitTests/RemoveEventLogDRTTests.cs
61 lines
3.2 KiB
PowerShell
61 lines
3.2 KiB
PowerShell
if ($IsWindows) {
|
|
#check to see whether we're running as admin in Windows...
|
|
$windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
$windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity
|
|
if ($windowsPrincipal.IsInRole("Administrators") -eq $true) {
|
|
$NonWinAdmin=$false
|
|
} else {$NonWinAdmin=$true}
|
|
}
|
|
|
|
|
|
Describe "Get-EventLog cmdlet tests" {
|
|
BeforeAll {
|
|
Remove-EventLog -LogName TestLog -ea Ignore
|
|
Remove-EventLog -LogName MissingTestLog -ea Ignore
|
|
New-EventLog -LogName TestLog -Source TestSource -ea Ignore
|
|
}
|
|
BeforeEach {
|
|
Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ea Ignore
|
|
}
|
|
AfterEach {
|
|
Clear-EventLog -LogName TestLog -ea Ignore
|
|
}
|
|
AfterAll {
|
|
Remove-EventLog -LogName TestLog -ea Ignore
|
|
}
|
|
It "should return an array of strings when called with -AsString parameter" -Skip:($IsLinux -Or $IsOSX) -Tag DRT {
|
|
{$result=Get-EventLog -AsString -ea stop} | Should Not Throw
|
|
{$result.GetType()|% { $_.IsArray }} | Should Be $true
|
|
{$result.Contains("System")} | Should Be $true
|
|
{$result.Contains("TestLog")} | Should Be $true
|
|
($result.Count -ge 4) | Should Be $true
|
|
}
|
|
It "should return a list of strings when called with -List parameter" -Skip:($IsLinux -Or $IsOSX) -Tag DRT {
|
|
{$result=Get-EventLog -List -ea stop} | Should Not Throw
|
|
{$result.GetType()|% { $_.IsArray }} | Should Be $true
|
|
{$logs=$result|Select -ExpandProperty Log} | Should Not Throw
|
|
{$logs.Contains("System")} | Should Be $true
|
|
{$logs.Contains("TestLog")} | Should Be $true
|
|
($logs.Count -ge 4) | Should Be $true
|
|
}
|
|
It "should be able to Get-EventLog -LogName Application -Newest 100" -Skip:($IsLinux -Or $IsOSX) -Tag DRT {
|
|
{$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].GetType().Name) | Should Be EventLog
|
|
}
|
|
It "should throw 'ParameterBindingException' when called with both -List and -AsString" -Skip:($IsLinux -Or $IsOSX) -Tag DRT {
|
|
{Get-EventLog -LogName MissingTestLog -ea stop} | Should Throw
|
|
}
|
|
It "should be able to Get-EventLog -LogName * with multiple matches" -Skip:($IsLinux -Or $IsOSX) -Tag DRT {
|
|
{$result=get-eventlog -LogName * -ea stop}| Should Not Throw
|
|
($result) | Should Not BeNullOrEmpty
|
|
{$result.Contains("System")} | Should Be $true
|
|
{$result.Contains("TestLog")} | Should Be $true
|
|
($result.count -ge 4) | Should Be $true
|
|
}
|
|
It "should throw 'The Log name 'MissingTestLog' does not exist' when asked to get a log that does not exist" -Skip:($IsLinux -Or $IsOSX) -Tag DRT {
|
|
{Get-EventLog -LogName MissingTestLog -ea stop} | Should Throw 'does not exist'
|
|
}
|
|
}
|