mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +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
56 lines
2.7 KiB
PowerShell
56 lines
2.7 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
|
|
}
|
|
}
|
|
|
|
It "should be able to create a New-EventLog with a -Source parameter" -Skip:($True) {
|
|
{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 parameter" -Skip:($True) {
|
|
{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 parameter" -Skip:($True) {
|
|
{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 parameter" -Skip:($True) {
|
|
{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 parameter" -Skip:($True) {
|
|
{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
|
|
}
|
|
}
|