-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Add-WorkingDays.Tests.ps1 +semver:skip
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BeforeAll { | ||
# Always use built code if running in a pipeline | ||
if ($env:USER -eq 'runner') { | ||
Import-Module "$PSScriptRoot/../../build/PSBusinessTime/PSBusinessTime.psd1" -Force | ||
} | ||
# Check if module is already imported, as it can be via VSCode task where you can choose what code base to test | ||
# and you might not want to cloober it with the non-built code | ||
elseif (-not (Get-Module PSBusinessTime)) { | ||
Import-Module "$PSScriptRoot/../../src/PSBusinessTime.psd1" -Force | ||
} | ||
} | ||
|
||
Describe "Add-WorkingDays" { | ||
It "should be 2022-04-19 as 3 working days from 2022-04-14" { | ||
Add-WorkingDays -Date (Get-Date '2022-04-14') -Days 3 | Should -Be (Get-Date '2022-04-19') | ||
} | ||
|
||
It "should be 2022-04-11 as -3 working days from 2022-04-14" { | ||
Add-WorkingDays -Date (Get-Date '2022-04-14') -Days -3 | Should -Be (Get-Date '2022-04-11') | ||
} | ||
|
||
It "should be 2022-04-21 as 3 working days from 2022-04-14, with Good Friday and Easter Monday holidays" { | ||
Add-WorkingDays -Date (Get-Date '2022-04-14') -Days 3 -NonWorkingDates (Get-Date '2022-04-15'),(Get-Date '2022-04-18') | Should -Be (Get-Date '2022-04-21') | ||
} | ||
|
||
It "should be 2022-04-21 as 3 working days from 2022-04-14, excluding Friday, Saturday, Sunday, and Monday, as working days" { | ||
Add-WorkingDays -Date (Get-Date '2022-04-14') -Days 3 -NonWorkingDaysOfWeek 'Friday','Saturday','Sunday','Monday' | Should -Be (Get-Date '2022-04-21') | ||
} | ||
} |