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
53 lines
3.1 KiB
PowerShell
53 lines
3.1 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 "New-EventLog cmdlet tests" {
|
|
BeforeEach {
|
|
Remove-EventLog -LogName TestLog -ea Ignore
|
|
}
|
|
It "should be able to create a New-EventLog with a -Source paramter" -Skip:($NonWinAdmin -or $IsLinux -Or $IsOSX) -Tag DRT {
|
|
{New-EventLog -LogName TestLog -Source TestSource -ea stop} | Should Not Throw
|
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ea stop} | Should Not Throw
|
|
$result=Get-EventLog -LogName TestLog
|
|
$result.Count | Should be 1
|
|
}
|
|
It "should be able to create a New-EventLog with a -ComputerName paramter" -Skip:($NonWinAdmin -or $IsLinux -Or $IsOSX) -Tag DRT {
|
|
{New-EventLog -LogName TestLog -Source TestSource -ComputerName $env:COMPUTERNAME -ea stop} | Should Not Throw
|
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ea stop} | Should Not Throw
|
|
$result=Get-EventLog -LogName TestLog
|
|
$result.Count | Should be 1
|
|
$result.EventID | Should be 1
|
|
}
|
|
It "should be able to create a New-EventLog with a -CategoryResourceFile paramter" -Skip:($NonWinAdmin -or $IsLinux -Or $IsOSX) -Tag DRT {
|
|
{New-EventLog -LogName TestLog -Source TestSource -CategoryResourceFile "CategoryMessageFile" -ea stop} | Should Not Throw
|
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 2 -ea stop} | Should Not Throw
|
|
$result=Get-EventLog -LogName TestLog
|
|
$result.Count | Should be 1
|
|
$result.EventID | Should be 2
|
|
}
|
|
It "should be able to create a New-EventLog with a -MessageResourceFile paramter" -Skip:($NonWinAdmin -or $IsLinux -Or $IsOSX) -Tag DRT {
|
|
{New-EventLog -LogName TestLog -Source TestSource -MessageResourceFile "ResourceMessageFile" -ea stop} | Should Not Throw
|
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 3 -ea stop} | Should Not Throw
|
|
$result=Get-EventLog -LogName TestLog
|
|
$result.Count | Should be 1
|
|
$result.EventID | Should be 3
|
|
}
|
|
It "should be able to create a New-EventLog with a -ParameterResourceFile paramter" -Skip:($NonWinAdmin -or $IsLinux -Or $IsOSX) -Tag DRT {
|
|
{New-EventLog -LogName TestLog -Source TestSource -ParameterResourceFile "ParameterMessageFile" -ea stop} | Should Not Throw
|
|
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 4 -ea stop} | Should Not Throw
|
|
$result=Get-EventLog -LogName TestLog
|
|
$result.Count | Should be 1
|
|
$result.EventID | Should be 4
|
|
}
|
|
It "should throw 'The Log name 'MissingTestLog' does not exist' when asked to clear a log that does not exist" -Tag DRT {
|
|
{Clear-EventLog -LogName MissingTestLog -ea stop} | Should Throw 'The Log name "MissingTestLog" does not exist'
|
|
}
|
|
}
|