From 9bd33dc928734d9d6f96afef115bd2d8bf8d3042 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 17:10:53 +0100 Subject: [PATCH 1/2] Add Name parameter to Get-Greeting function --- src/functions/public/Get-Greeting.ps1 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/functions/public/Get-Greeting.ps1 b/src/functions/public/Get-Greeting.ps1 index 586e0d3..37712c2 100644 --- a/src/functions/public/Get-Greeting.ps1 +++ b/src/functions/public/Get-Greeting.ps1 @@ -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' @@ -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/ #> @@ -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!" + } } From 443614358e444f594f0b9fcbab6343d3dd4df1cb Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 17:19:44 +0100 Subject: [PATCH 2/2] Add tests for Get-Greeting Name parameter --- tests/PSModuleTest.Tests.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/PSModuleTest.Tests.ps1 b/tests/PSModuleTest.Tests.ps1 index 01955e8..93e0177 100644 --- a/tests/PSModuleTest.Tests.ps1 +++ b/tests/PSModuleTest.Tests.ps1 @@ -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}$'