mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-18 05:05:36 +00:00
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files. Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks. Separate PR coming to update contribution document for new source files: #6140 Manually reviewed each change. Fix #6073
39 lines
2.4 KiB
PowerShell
39 lines
2.4 KiB
PowerShell
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
|
|
|
|
BeforeAll {
|
|
$defaultParamValues = $PSdefaultParameterValues.Clone()
|
|
$IsNotSkipped = ($IsWindows -and !$IsCoreCLR)
|
|
$PSDefaultParameterValues["it:skip"] = !$IsNotSkipped
|
|
}
|
|
|
|
AfterAll {
|
|
$global:PSDefaultParameterValues = $defaultParamValues
|
|
}
|
|
|
|
BeforeEach {
|
|
if ($IsNotSkipped) {
|
|
Remove-EventLog -LogName TestLog -ea Ignore
|
|
{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
|
|
}
|
|
}
|
|
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
|
|
It "should be able to Remove-EventLog -LogName <string> -ComputerName <string>" -Pending:($True) {
|
|
{Remove-EventLog -LogName TestLog -ComputerName $env:COMPUTERNAME -ea Stop} | Should Not Throw
|
|
try {Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ea Stop; Throw "Previous statement unexpectedly succeeded..."
|
|
} catch {$_.FullyQualifiedErrorId | Should Be "Microsoft.PowerShell.Commands.WriteEventLogCommand"}
|
|
try {Get-EventLog -LogName TestLog -ea Stop; Throw "Previous statement unexpectedly succeeded..."
|
|
} catch {$_.FullyQualifiedErrorId | Should Be "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"}
|
|
}
|
|
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
|
|
It "should be able to Remove-EventLog -Source <string> -ComputerName <string>" -Pending:($True) {
|
|
{Remove-EventLog -Source TestSource -ComputerName $env:COMPUTERNAME -ea Stop} | Should Not Throw
|
|
try {Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ea Stop; Throw "Previous statement unexpectedly succeeded..."
|
|
} catch {$_.FullyQualifiedErrorId | Should Be "Microsoft.PowerShell.Commands.WriteEventLogCommand"}
|
|
try {Get-EventLog -LogName TestLog -ea Stop; Throw "Previous statement unexpectedly succeeded..."
|
|
} catch {$_.FullyQualifiedErrorId | Should Be "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"}
|
|
}
|
|
}
|