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
18 changes: 16 additions & 2 deletions src/functions/public/Get-Greeting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

.DESCRIPTION
Returns a simple greeting message for the specified time of day.
Optionally includes the user's name in the greeting.

.EXAMPLE
Get-Greeting -TimeOfDay 'Morning'
Expand All @@ -16,6 +17,11 @@

Returns "Good Evening!" to the user.

.EXAMPLE
Get-Greeting -TimeOfDay 'Morning' -Name 'Alice'

Returns "Good Morning, Alice!" to the user.

.LINK
https://MariusStorhaug.github.io/MariusTestModule/Functions/Get-Greeting/
#>
Expand All @@ -25,7 +31,15 @@
# The time of day for the greeting.
[Parameter()]
[ValidateSet('Morning', 'Afternoon', 'Evening')]
[string] $TimeOfDay = 'Morning'
[string] $TimeOfDay = 'Morning',

# Optional name to include in the greeting.
[Parameter()]
[string] $Name
)
"Good $TimeOfDay!"
if ($Name) {
"Good $TimeOfDay, $Name!"
} else {
"Good $TimeOfDay!"
}
}
12 changes: 12 additions & 0 deletions tests/PSModuleTest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ Describe 'Module' {
Get-Greeting -TimeOfDay 'Evening' | Should -Be 'Good Evening!'
}

It 'Function: Get-Greeting - With Name' {
Get-Greeting -Name 'Alice' | Should -Be 'Good Morning, Alice!'
}

It 'Function: Get-Greeting - Evening with Name' {
Get-Greeting -TimeOfDay 'Evening' -Name 'Bob' | Should -Be 'Good Evening, Bob!'
}

It 'Function: Get-Greeting - Afternoon with Name' {
Get-Greeting -TimeOfDay 'Afternoon' -Name 'Charlie' | Should -Be 'Good Afternoon, Charlie!'
}

It 'Function: Get-CurrentDateTime - Default format' {
$result = Get-CurrentDateTime
$result | Should -Match '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'
Expand Down
Loading