File size: 2,921 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # Copyright (c) Microsoft Corporation.
# 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 -ErrorAction Ignore
}
}
It "should be able to create a New-EventLog with a -Source parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction 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 parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ComputerName $env:COMPUTERNAME -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction 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 parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -CategoryResourceFile "CategoryMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 2 -ErrorAction 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 parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -MessageResourceFile "ResourceMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 3 -ErrorAction 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 parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ParameterResourceFile "ParameterMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 4 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
$result.EventID | Should -Be 4
}
}
|