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
38 changes: 38 additions & 0 deletions .github/workflows/toolbox-alignment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Standalone toolbox alignment

on:
push:
branches: [master]
paths: ['New-StringConversion.ps1', 'Test-IsEmail.ps1', 'Test-IsValidDn.ps1', 'Get-ElapsedTime.ps1', 'Private/**', 'Tests/ToolboxAlignment.Tests.ps1', '.github/workflows/toolbox-alignment.yml']
pull_request:
paths: ['New-StringConversion.ps1', 'Test-IsEmail.ps1', 'Test-IsValidDn.ps1', 'Get-ElapsedTime.ps1', 'Private/**', 'Tests/ToolboxAlignment.Tests.ps1', '.github/workflows/toolbox-alignment.yml']
workflow_dispatch:

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install and run Pester
run: |
$ErrorActionPreference = 'Stop'
Install-Module Pester -RequiredVersion 5.7.1 -Scope CurrentUser -Force -Repository PSGallery
Import-Module Pester -RequiredVersion 5.7.1 -Force
$configuration = New-PesterConfiguration
$configuration.Run.Path = @('./Tests/New-ApiRequest.Tests.ps1', './Tests/ToolboxAlignment.Tests.ps1')
$configuration.Run.Exit = $true
$configuration.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $configuration
69 changes: 22 additions & 47 deletions Get-ElapsedTime.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#Requires -Version 7.4

function Get-ElapsedTime
{
<#
Expand Down Expand Up @@ -48,10 +50,12 @@ function Get-ElapsedTime
System.TimeSpan, System.Double, System.Int32
#>

[CmdletBinding(DefaultParameterSetName = 'FullOutput',
ConfirmImpact = 'High',
SupportsPaging = $false,
SupportsShouldProcess = $false)]
[CmdletBinding(
DefaultParameterSetName = 'FullOutput',
ConfirmImpact = 'High',
SupportsPaging = $false,
SupportsShouldProcess = $false
)]
[OutputType([timespan], ParameterSetName = 'FullOutput')]
[OutputType([int], ParameterSetName = 'Days')]
[OutputType([int], ParameterSetName = 'Hours')]
Expand All @@ -63,48 +67,19 @@ function Get-ElapsedTime
[OutputType([double], ParameterSetName = 'TotalSeconds')]
[OutputType([double], ParameterSetName = 'TotalMilliseconds')]
[OutputType([timespan])]
param
(
[Parameter(ParameterSetName = 'FullOutput',
Mandatory = $true)]
[Parameter(ParameterSetName = 'Days')]
[Parameter(ParameterSetName = 'Hours')]
[Parameter(ParameterSetName = 'Minutes')]
[Parameter(ParameterSetName = 'Seconds')]
[Parameter(ParameterSetName = 'TotalDays')]
[Parameter(ParameterSetName = 'TotalHours')]
[Parameter(ParameterSetName = 'TotalMilliseconds')]
[Parameter(ParameterSetName = 'TotalMinutes')]
[Parameter(ParameterSetName = 'TotalSeconds')]
[System.Diagnostics.Stopwatch]
$ElapsedTime,
[Parameter(ParameterSetName = 'Days')]
[switch]
$Days,
[Parameter(ParameterSetName = 'Hours')]
[switch]
$Hours,
[Parameter(ParameterSetName = 'Minutes')]
[switch]
$Minutes,
[Parameter(ParameterSetName = 'Seconds')]
[switch]
$Seconds,
[Parameter(ParameterSetName = 'TotalDays')]
[switch]
$TotalDays,
[Parameter(ParameterSetName = 'TotalHours')]
[switch]
$TotalHours,
[Parameter(ParameterSetName = 'TotalMinutes')]
[switch]
$TotalMinutes,
[Parameter(ParameterSetName = 'TotalSeconds')]
[switch]
$TotalSeconds,
[Parameter(ParameterSetName = 'TotalMilliseconds')]
[switch]
$TotalMilliseconds
param(
[Parameter(Mandatory = $true)]
[ValidateNotNull()]
[System.Diagnostics.Stopwatch]$ElapsedTime,
[Parameter(ParameterSetName = 'Days')][switch]$Days,
[Parameter(ParameterSetName = 'Hours')][switch]$Hours,
[Parameter(ParameterSetName = 'Minutes')][switch]$Minutes,
[Parameter(ParameterSetName = 'Seconds')][switch]$Seconds,
[Parameter(ParameterSetName = 'TotalDays')][switch]$TotalDays,
[Parameter(ParameterSetName = 'TotalHours')][switch]$TotalHours,
[Parameter(ParameterSetName = 'TotalMinutes')][switch]$TotalMinutes,
[Parameter(ParameterSetName = 'TotalSeconds')][switch]$TotalSeconds,
[Parameter(ParameterSetName = 'TotalMilliseconds')][switch]$TotalMilliseconds
)

switch ($PsCmdlet.ParameterSetName)
Expand Down Expand Up @@ -180,4 +155,4 @@ function Get-ElapsedTime
break
}
}
}
}
Loading
Loading