Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/copilot-pull-request-description-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ References:
- https://seesparkbox.com/foundry/semantic_commit_messages
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html

## Pull Reques description
## Pull Request description

- Add a summery of the intention of the PR. Use the title and the messages of the commits to create a summary.
- Add a list with all the commit messages in the PR.
- Add a summary of the intention of the PR. Use the title and the messages of the commits to create a summary.
- Add a bullet list with all the commit messages in the PR commits.
8 changes: 5 additions & 3 deletions Test/include/run_BeforeAfter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
# Write-Verbose "Run_AfterAll"
# }

# function Run_BeforeEach{
# Write-Verbose "Run_BeforeEach"
# }
function Run_BeforeEach{
# Write-Verbose "Run_BeforeEach"
Disable-IncludeHelperDebug

}

# function Run_AfterEach{
# Write-Verbose "Run_AfterEach"
Expand Down
242 changes: 242 additions & 0 deletions Test/public/MyWrite.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,248 @@
}
$result = Stop-MyTranscript

Assert-Count -Expected 2 -Presented $result
Assert-AreEqual -Expected "This is a test transcript 0" -Presented $result[0]
Assert-AreEqual -Expected "This is a test transcript 1" -Presented $result[1]
}

function Test_EnableMyDebug_Set{
# Arrange
Disable-IncludeHelperDebug
# Act
Enable-IncludeHelperDebug
# Assert
Assert-DebugEnv "all" ""

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
# Arrange
Disable-IncludeHelperDebug
# Act
Enable-IncludeHelperDebug -Sections "section0","section1"
# Assert
Assert-DebugEnv "section0 section1" ""

# Arrange
Disable-IncludeHelperDebug
# Act
Enable-IncludeHelperDebug -Sections "-section0-tofilter"
# Assert
Assert-DebugEnv "-section0-tofilter" ""

# Arrange
Disable-IncludeHelperDebug
# Act
Enable-IncludeHelperDebug -Sections "-section0-tofilter","-section1-tofilter"
# Assert
Assert-DebugEnv "-section0-tofilter -section1-tofilter" ""

# Arrange
Disable-IncludeHelperDebug
$logfilename = "testlog.log"
# Act
Enable-IncludeHelperDebug -LoggingFilePath $logfilename
# Assert
Assert-DebugEnv "" ""

# Arrange
Disable-IncludeHelperDebug
# Act
New-TestingFile -Name $logfilename
Enable-IncludeHelperDebug -LoggingFilePath $logfilename
# Assert
Assert-DebugEnv "all" $logfilename

}

function Test_EnableMyDebug_All{

Enable-IncludeHelperDebug

$result = [System.Environment]::GetEnvironmentVariable("IncludeHelper_DEBUG")
Assert-AreEqual -Expected "all" -Presented $result

$text0 = "Debug message 0"
$text1 = "Debug message 1"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0]

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[1]

} -Arguments $text0,$text1

$result = Stop-MyTranscript

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "none" $text0

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[1] "none" $text1

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.

}



function Test_EnableMyDebug_All_Sections{

Enable-IncludeHelperDebug

$text0 = "Debug message 0"
$text1 = "Debug message 1"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0] -Section "section0"
Write-MyDebug -Message $Arguments[1] -Section "section1"

} -Arguments $text0,$text1

$result = Stop-MyTranscript

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[1] "section1" $text1

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
}

function Test_EnableMyDebug_Sections{

Enable-IncludeHelperDebug -Sections "section0","section2"

$result = [System.Environment]::GetEnvironmentVariable("IncludeHelper_DEBUG")
Assert-AreEqual -Expected "section0 section2" -Presented $result

$text0 = "Debug message 0"
$text1 = "Debug message 1"
$text2 = "Debug message 2"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0] -Section "section0"
Write-MyDebug -Message $Arguments[1] -Section "section1"
Write-MyDebug -Message $Arguments[2] -Section "section2"

} -Arguments $text0,$text1,$text2

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

$result = Stop-MyTranscript

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[1] "section2" $text2

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
}

function Test_EnableMyDebug_All_Filter{

Enable-IncludeHelperDebug -Sections "-section1-tofilter"

$result = [System.Environment]::GetEnvironmentVariable("IncludeHelper_DEBUG")
Assert-AreEqual -Expected "-section1-tofilter" -Presented $result

$text0 = "Debug message 0"
$text1 = "Debug message 1"
$text2 = "Debug message 2"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0] -Section "section0"
Write-MyDebug -Message $Arguments[1] -Section "section1-tofilter"
Write-MyDebug -Message $Arguments[2] -Section "section2"

} -Arguments $text0,$text1,$text2

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

$result = Stop-MyTranscript

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[1] "section2" $text2

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
}

function Test_EnableMyDebug_All_Filter_morethanone{

Enable-IncludeHelperDebug -Sections "-section1-tofilter -section2ToFilter"

$result = [System.Environment]::GetEnvironmentVariable("IncludeHelper_DEBUG")
Assert-AreEqual -Expected "-section1-tofilter -section2ToFilter" -Presented $result

$text0 = "Debug message 0"
$text1 = "Debug message 1"
$text2 = "Debug message 2"
$text3 = "Debug message 3"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0] -Section "section0"
Write-MyDebug -Message $Arguments[1] -Section "section1-tofilter"
Write-MyDebug -Message $Arguments[2] -Section "section2ToFilter"
Write-MyDebug -Message $Arguments[3] -Section "section3"

} -Arguments $text0,$text1,$text2 ,$text3

$result = Stop-MyTranscript

Assert-Count -Expected 2 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[1] "section3" $text3

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
}

function Test_EnableMyDebug_All_LoggingFilePath{

$logfilename = "testlog.log"
touch $logfilename

Enable-IncludeHelperDebug -LoggingFilePath $logfilename

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

$text0 = "Debug message 0"
$text1 = "Debug message 1"
$text2 = "Debug message 2"
$text3 = "Debug message 3"

Start-MyTranscript

Invoke-PrivateContext {
param($Arguments)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Write-MyDebug -Message $Arguments[0] -Section "section0"
Write-MyDebug -Message $Arguments[1] -Section "section1-tofilter"
Write-MyDebug -Message $Arguments[2] -Section "section2ToFilter"
Write-MyDebug -Message $Arguments[3] -Section "section3"

} -Arguments $text0,$text1,$text2 ,$text3

$result = Stop-MyTranscript

Assert-Count -Expected 4 -Presented $result

$result = Get-Content $logfilename
Assert-Count -Expected 4 -Presented $result
Assert-DbgMsg $result[0] "section0" $text0

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[1] "section1-tofilter" $text1

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[2] "section2ToFilter" $text2

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
Assert-DbgMsg $result[3] "section3" $text3

Check notice

Code scanning / PSScriptAnalyzer

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command. Note

Cmdlet 'Assert-DbgMsg' has positional parameter. Please use named parameters instead of positional parameters when calling a command.
}

function Assert-DbgMsg($Presented,$Section,$Message){

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
Assert-IsTrue -Condition ($Presented -match "^\[\d{2}:\d{2}:\d{2}\.\d{3}\]\[D\]\[$Section\] $Message$")
}

function Assert-DebugEnv($SectionString,$LoggingFile){
$result = [System.Environment]::GetEnvironmentVariable("IncludeHelper_DEBUG")
$result = $result ?? ""
Assert-AreEqual -Expected $SectionString -Presented $result

$result = [System.Environment]::GetEnvironmentVariable("IncludeHelper_DEBUG_LOGGING_FILEPATH")
$result = $result ?? ""
Assert-AreEqual -Expected $LoggingFile -Presented $result
}
Loading
Loading