Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Assert assertions to Pester #2428

Merged
merged 63 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
567549c
Copy paste assert
nohwnd Apr 1, 2024
28761e6
Before adding format nicely2
nohwnd Apr 1, 2024
079d374
Few more tests
nohwnd Apr 1, 2024
cfaa965
Add code, did not fix help yet
nohwnd Apr 2, 2024
911a465
Fix $error
nohwnd Apr 6, 2024
0bf4752
Fix warnings
nohwnd Apr 6, 2024
b54b003
Fix collecting from pipeline
nohwnd Apr 6, 2024
6575ca4
Merge branch 'main' into add-assert
nohwnd Apr 7, 2024
50182d9
wip
nohwnd Apr 7, 2024
333417c
Fix input collecting
nohwnd Apr 7, 2024
0230d8c
Remove Compatibility.ps1
nohwnd Apr 7, 2024
3d1d896
Add Should-* aliases
nohwnd Apr 7, 2024
b0ffc38
Rename internal Should-* functions to Should-*Assertion to avoid conf…
nohwnd Apr 7, 2024
d60f535
Fix raw get-variable
nohwnd Apr 12, 2024
1815b55
Merge branch 'dev/6.x.x' into add-assert
nohwnd Apr 12, 2024
36f36c9
No SDK pre-release
nohwnd Apr 12, 2024
9829ae1
Fixes
nohwnd Apr 19, 2024
9143030
Add Should-BeEmptyString and fix formatting
nohwnd Apr 19, 2024
6e79b45
Build on dev/*
nohwnd Apr 20, 2024
e5a4446
Add not be null or empty, and not be null or whitespace string assert…
nohwnd Apr 20, 2024
0560d77
formatting almost fixed
nohwnd Apr 20, 2024
5b1ebd4
Change formats, fix all tests
nohwnd Apr 21, 2024
5b54c22
Update azure-pipelines.yml
nohwnd Apr 21, 2024
60c3a12
Add faster and before date time
nohwnd Apr 21, 2024
67e886d
Merge branch 'add-assert' of https://github.com/pester/Pester into ad…
nohwnd Apr 21, 2024
9e43582
Faster, slower, before, after
nohwnd Apr 23, 2024
0e5c073
before, after, faster, slower
nohwnd Apr 23, 2024
1565699
Strict mode
nohwnd Apr 23, 2024
d80c7ef
Fix running tests
nohwnd Apr 23, 2024
caaffae
all and any
nohwnd Apr 23, 2024
cc03bf4
all and any
nohwnd Apr 23, 2024
bdc7fcf
Why did pass thru failing now? :/
nohwnd Apr 23, 2024
28ae51f
Rename assertion files
nohwnd Apr 25, 2024
c70bdd2
rename some files
nohwnd Apr 25, 2024
6dd68d6
Continue on renaming and using Should-* in tests
nohwnd Apr 26, 2024
432e02d
Rename assertions and tests, and use assertion functions so we are su…
nohwnd Apr 26, 2024
b5f8da4
Fix tests
nohwnd May 1, 2024
2f262f3
Change messages,tests are broken
nohwnd May 1, 2024
13307ca
Fix messages
nohwnd May 3, 2024
ab36078
Fix more messages
nohwnd May 3, 2024
a1f283c
Little bit of help
nohwnd May 3, 2024
8509a5c
Add help
nohwnd May 7, 2024
4c8bae2
info
nohwnd May 7, 2024
a6affe3
unroll
nohwnd May 7, 2024
3c74309
Add Help
nohwnd May 14, 2024
46f46ac
Add help and put back help tests
nohwnd May 14, 2024
81ac71d
Merge branch 'main' into add-assert
nohwnd May 18, 2024
90a887d
assert
nohwnd May 18, 2024
7a971c5
Update src/functions/assert/General/Should-NotHaveType.ps1
nohwnd May 20, 2024
a18e746
Update src/functions/assert/General/Should-HaveType.ps1
nohwnd May 20, 2024
1b3f0b5
Update src/functions/assert/Equivalence/Should-BeEquivalent.ps1
nohwnd May 20, 2024
29f5cb8
Revert test, fix safe commands etc.
nohwnd May 20, 2024
7931820
Merge branch 'add-assert' of https://github.com/pester/Pester into ad…
nohwnd May 20, 2024
03e28d0
Revert launch.json
nohwnd May 20, 2024
bf19cb3
Remove TimeSpanOrStringWithTimeUnit.cs
nohwnd May 20, 2024
f1a3810
Apply suggestions from code review
nohwnd May 20, 2024
40595dc
Merge branch 'add-assert' of https://github.com/pester/Pester into ad…
nohwnd May 20, 2024
4e67f2f
Apply suggestions from code review
nohwnd May 20, 2024
0e17209
Fixes
nohwnd May 20, 2024
548e373
Merge branch 'add-assert' of https://github.com/pester/Pester into ad…
nohwnd May 20, 2024
162fab7
Get-equivalencyoption help
nohwnd May 20, 2024
6fa12ce
Get-equivalencyoption help
nohwnd May 20, 2024
c7886fb
Merge branch 'main' into add-assert
nohwnd May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ vendor/packages/
.vscode/
# But don't exclude settings.json
!.vscode/settings.json
!.vscode/launch.json

coverage.xml
testResults.xml
Expand Down
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell: Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": []
},
{
"name": "Pester: Tests from current file",
"type": "PowerShell",
"request": "launch",
"script": "${workspaceFolder}/test.ps1",
"args": [
"-File",
"${file}"
]
},
{
"name": "Pester: All tests",
"type": "PowerShell",
"request": "launch",
"script": "${workspaceFolder}/test.ps1",
"args": []
}
]
}
3 changes: 3 additions & 0 deletions src/Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $script:SafeCommands['Set-DynamicParameterVariable'] = $ExecutionContext.Session
& $SafeCommands['Set-Alias'] 'Should-BeFasterThan' 'Assert-Faster'
& $SafeCommands['Set-Alias'] 'Should-BeSlowerThan' 'Assert-Slower'
& $SafeCommands['Set-Alias'] 'Should-BeBefore' 'Assert-Before'
& $SafeCommands['Set-Alias'] 'Should-BeAfter' 'Assert-After'



Expand Down Expand Up @@ -109,6 +110,7 @@ $script:SafeCommands['Set-DynamicParameterVariable'] = $ExecutionContext.Session
'Assert-Faster'
'Assert-Slower'
'Assert-Before'
'Assert-After'

# export
'Export-NUnitReport'
Expand Down Expand Up @@ -168,4 +170,5 @@ $script:SafeCommands['Set-DynamicParameterVariable'] = $ExecutionContext.Session
'Should-BeFasterThan'
'Should-BeSlowerThan'
'Should-BeBefore'
'Should-BeAfter'
)
2 changes: 2 additions & 0 deletions src/Pester.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'Assert-Faster'
'Assert-Slower'
'Assert-Before'
'Assert-After'

# legacy
'Assert-VerifiableMock'
Expand Down Expand Up @@ -158,6 +159,7 @@
'Should-BeFasterThan'
'Should-BeSlowerThan'
'Should-BeBefore'
'Should-BeAfter'
)


Expand Down
51 changes: 51 additions & 0 deletions src/functions/assert/Time/Assert-After.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function Assert-After {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseProcessBlockForPipelineCommand', '')]
[CmdletBinding(DefaultParameterSetName = "Now")]
param (
[Parameter(Position = 2, ValueFromPipeline = $true)]
$Actual,

[Parameter(Position = 0, ParameterSetName = "Now")]
[switch] $Now,

[Parameter(Position = 0, ParameterSetName = "Fluent")]
$Time,

[Parameter(Position = 1, ParameterSetName = "Fluent")]
[switch] $Ago,

[Parameter(Position = 1, ParameterSetName = "Fluent")]
[switch] $FromNow,

[Parameter(Position = 0, ParameterSetName = "Expected")]
[DateTime] $Expected
)

# Now is just a syntax marker, we don't need to do anything with it.
$Now = $Now

$currentTime = [datetime]::UtcNow.ToLocalTime()
if ($PSCmdlet.ParameterSetName -eq "Expected") {
# do nothing we already have expected value
}
elseif ($PSCmdlet.ParameterSetName -eq "Now") {
$Expected = $currentTime
}
else {
if ($Ago -and $FromNow -or (-not $Ago -and -not $FromNow)) {
throw "You must provide either -Ago or -FromNow switch, but not both or none."
}

if ($Ago) {
$Expected = $currentTime - (Get-TimeSpanFromStringWithUnits -Value $Time)
}
else {
$Expected = $currentTime + (Get-TimeSpanFromStringWithUnits -Value $Time)
}
}

if ($Actual -le $Expected) {
$Message = Get-AssertionMessage -Expected $Expected -Actual $Actual -CustomMessage $CustomMessage -Data @{ ago = $Ago } -DefaultMessage "Expected the provided [datetime] to be after <expectedType> <expected> (<ago> ago),<because> but it was before: <actual>"
throw [Pester.Factory]::CreateShouldErrorRecord($Message, $MyInvocation.ScriptName, $MyInvocation.ScriptLineNumber, $MyInvocation.Line.TrimEnd([System.Environment]::NewLine), $true)
}
}
62 changes: 36 additions & 26 deletions src/functions/assert/Time/Assert-Before.ps1
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
function Assert-Before {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseProcessBlockForPipelineCommand', '')]
[CmdletBinding(DefaultParameterSetName = "Now")]
param (
[Parameter(Position = 1, ValueFromPipeline = $true)]
[Parameter(Position = 2, ValueFromPipeline = $true)]
$Actual,
[Parameter(Position = 0, ParameterSetName = "Expected")]
[DateTime] $Expected,

[Parameter(Position = 0, ParameterSetName = "Ago")]
$TimeAgo,
[Parameter(Position = 0, ParameterSetName = "Now")]
[switch] $Now,

[Parameter(Position = 0, ParameterSetName = "Fluent")]
$Time,

[Parameter(Position = 1, ParameterSetName = "Fluent")]
[switch] $Ago,

[Parameter(Position = 1, ParameterSetName = "Fluent")]
[switch] $FromNow,
nohwnd marked this conversation as resolved.
Show resolved Hide resolved

[Parameter(Position = 0, ParameterSetName = "FromNow")]
$TimeFromNow
[Parameter(Position = 0, ParameterSetName = "Expected")]
[DateTime] $Expected
)

$now = [datetime]::UtcNow.ToLocalTime()
# Now is just a syntax marker, we don't need to do anything with it.
$Now = $Now

$currentTime = [datetime]::UtcNow.ToLocalTime()
if ($PSCmdlet.ParameterSetName -eq "Expected") {
if ($Actual -ge $Expected) {
$Message = Get-AssertionMessage -Expected $Expected -Actual $Actual -CustomMessage $CustomMessage -DefaultMessage "The provided [datetime] should be before <expectedType> <expected>,<because> but it was after: <actual>"
throw [Pester.Factory]::CreateShouldErrorRecord($Message, $MyInvocation.ScriptName, $MyInvocation.ScriptLineNumber, $MyInvocation.Line.TrimEnd([System.Environment]::NewLine), $true)
}
return
# do nothing we already have expected value
}

if ($PSCmdlet.ParameterSetName -eq "Ago") {
$Expected = $now - (Get-TimeSpanFromStringWithUnits -Value $TimeAgo)
if ($Actual -ge $Expected) {
$Message = Get-AssertionMessage -Expected $Expected -Actual $Actual -CustomMessage $CustomMessage -Data @{ ago = $TimeAgo } -DefaultMessage "The provided [datetime] should be before <expectedType> <expected> (<ago> ago),<because> but it was after: <actual>"
throw [Pester.Factory]::CreateShouldErrorRecord($Message, $MyInvocation.ScriptName, $MyInvocation.ScriptLineNumber, $MyInvocation.Line.TrimEnd([System.Environment]::NewLine), $true)
}
return
elseif ($PSCmdlet.ParameterSetName -eq "Now") {
$Expected = $currentTime
}
else {
$Expected = $now - (Get-TimeSpanFromStringWithUnits -Value $TimeFromNow)
if ($Actual -ge $Expected) {
$Message = Get-AssertionMessage -Expected $Expected -Actual $Actual -CustomMessage $CustomMessage -Data @{ fromNow = $TimeFromNow } -DefaultMessage "The provided [datetime] should be before <expectedType> <expected> (<fromNow> from now),<because> but it was after: <actual>"
throw [Pester.Factory]::CreateShouldErrorRecord($Message, $MyInvocation.ScriptName, $MyInvocation.ScriptLineNumber, $MyInvocation.Line.TrimEnd([System.Environment]::NewLine), $true)
if ($Ago -and $FromNow -or (-not $Ago -and -not $FromNow)) {
throw "You must provide either -Ago or -FromNow switch, but not both or none."
}

if ($Ago) {
$Expected = $currentTime - (Get-TimeSpanFromStringWithUnits -Value $Time)
}
return
else {
$Expected = $currentTime + (Get-TimeSpanFromStringWithUnits -Value $Time)
}
}

if ($Actual -ge $Expected) {
$Message = Get-AssertionMessage -Expected $Expected -Actual $Actual -CustomMessage $CustomMessage -Data @{ ago = $Ago } -DefaultMessage "Expected the provided [datetime] to be before <expectedType> <expected> (<ago> ago),<because> but it was after: <actual>"
throw [Pester.Factory]::CreateShouldErrorRecord($Message, $MyInvocation.ScriptName, $MyInvocation.ScriptLineNumber, $MyInvocation.Line.TrimEnd([System.Environment]::NewLine), $true)
}
}
2 changes: 1 addition & 1 deletion src/functions/assert/Time/Assert-Faster.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Assert-Faster {
$sw.Stop()

if ($sw.Elapsed -ge $Expected) {
$Message = Get-AssertionMessage -Expected $Expected -Actual $sw.Elapsed -CustomMessage $CustomMessage -Data @{ scriptblock = $Actual } -DefaultMessage "The provided [scriptblock] should execute faster than <expectedType> <expected>,<because> but it took <actual> to run.`nActual: <scriptblock>"
$Message = Get-AssertionMessage -Expected $Expected -Actual $sw.Elapsed -CustomMessage $CustomMessage -Data @{ scriptblock = $Actual } -DefaultMessage "Expected the provided [scriptblock] to execute faster than <expectedType> <expected>,<because> but it took <actual> to run.`nScriptBlock: <scriptblock>"
throw [Pester.Factory]::CreateShouldErrorRecord($Message, $MyInvocation.ScriptName, $MyInvocation.ScriptLineNumber, $MyInvocation.Line.TrimEnd([System.Environment]::NewLine), $true)
}
return
Expand Down
2 changes: 1 addition & 1 deletion src/functions/assert/Time/Assert-Slower.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$sw.Stop()

if ($sw.Elapsed -le $Expected) {
$Message = Get-AssertionMessage -Expected $Expected -Actual $sw.Elapsed -CustomMessage $CustomMessage -Data @{ scriptblock = $Actual } -DefaultMessage "The provided [scriptblock] should execute slower than <expectedType> <expected>,<because> but it took <actual> to run.`nActual: <scriptblock>"
$Message = Get-AssertionMessage -Expected $Expected -Actual $sw.Elapsed -CustomMessage $CustomMessage -Data @{ scriptblock = $Actual } -DefaultMessage "The provided [scriptblock] should execute slower than <expectedType> <expected>,<because> but it took <actual> to run.`nScriptBlock: <scriptblock>"
throw [Pester.Factory]::CreateShouldErrorRecord($Message, $MyInvocation.ScriptName, $MyInvocation.ScriptLineNumber, $MyInvocation.Line.TrimEnd([System.Environment]::NewLine), $true)
}
return
Expand Down
18 changes: 16 additions & 2 deletions test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ $ErrorView = "NormalView"
"Using PS: $($PsVersionTable.PSVersion)"
"In path: $($pwd.Path)"

if ($CI -and ($SkipPTests -or $SkipPesterTests)) {
throw "Cannot skip tests in CI mode!"
# Detect which tests to skip from the filenames.
$anyPesterTests = [bool]@($File | Where-Object { $_ -like "*.Tests.ps1" })
$anyPTests = [bool]@($File | Where-Object { $_ -like "*.ts.ps1" })

if ($anyPTests -and $anyPesterTests) {
# Don't skip P or Pester tests, use the parameters user provided.
}
elseif (-not $SkipPTests.IsPresent -and (-not $anyPTests)) {
$SkipPTests = $true
}
elseif (-not $SkipPesterTests.IsPresent -and (-not $anyPesterTests)) {
$SkipPesterTests = $true
}

if (-not $NoBuild) {
Expand All @@ -62,6 +72,10 @@ if (-not $NoBuild) {
}
}

if ($CI -and ($SkipPTests -or $SkipPesterTests)) {
throw "Cannot skip tests in CI mode!"
}

# remove pester because we will be reimporting it in multiple other places
Get-Module Pester | Remove-Module

Expand Down
58 changes: 51 additions & 7 deletions tst/functions/assert/Time/Should-BeAfter.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,59 @@
Set-StrictMode -Version Latest

Describe "Should-BeSlowerThan" {
It "Does not throw when actual is slower than expected" -ForEach @(
@{ Actual = { Start-Sleep -Milliseconds 10 }; Expected = "1ms" }
Describe "Should-BeAfter" {
It "Does not throw when actual date is before expected date" -ForEach @(
@{ Actual = [DateTime]::Now.AddDays(1); Expected = [DateTime]::Now }
) {
$Actual | Should-BeSlowerThan -Expected $Expected
$Actual | Should-BeAfter -Expected $Expected
}

It "Does not throw when actual is slower than expected taking TimeSpan" -ForEach @(
@{ Actual = [timespan]::FromMilliseconds(999); Expected = "1ms" }
It "Does not throw when actual date is before expected date using ago" {
[DateTime]::Now.AddMinutes(11) | Should-BeAfter 10minutes -Ago
}

It "Does not throw when actual date is before expected date using fromNow" {
[DateTime]::Now.Add([timespan]::FromMinutes(20)) | Should-BeAfter 10minutes -FromNow
}

It "Does not throw when actual date is before expected date using Now" {
[DateTime]::Now.Add([timespan]::FromMinutes(20)) | Should-BeAfter -Now
}

It "Does not throw when actual date is before expected date using Now parameter set but not providing any switch" {
[DateTime]::Now.Add([timespan]::FromMinutes(20)) | Should-BeAfter
}

It "Throws when actual date is before expected date" -ForEach @(
@{ Actual = [DateTime]::Now.AddDays(-1); Expected = [DateTime]::Now }
) {
$Actual | Should-BeSlowerThan -Expected $Expected
{ $Actual | Should-BeAfter -Expected $Expected } | Verify-AssertionFailed
}

It "Throws when actual date is before expected date using ago" {
{ [DateTime]::Now.AddMinutes(-11) | Should-BeAfter 10minutes -Ago } | Verify-AssertionFailed
}

It "Throws when actual date is before expected date using fromNow" {
{ [DateTime]::Now.Add([timespan]::FromMinutes(9)) | Should-BeAfter 10minutes -FromNow } | Verify-AssertionFailed
}

It "Throws when actual date is before expected date using Now" {
{ [DateTime]::Now.Add([timespan]::FromMinutes(-1)) | Should-BeAfter -Now } | Verify-AssertionFailed
}

It "Throws when actual date is before expected date using Now parameter set but not providing any switch" {
{ [DateTime]::Now.Add([timespan]::FromMinutes(-1)) | Should-BeAfter } | Verify-AssertionFailed
}

It "Throws when both -Ago and -FromNow are used" -ForEach @(
) {
{ $Actual | Should-BeAfter 10minutes -Ago -FromNow } | Verify-Throw
}

It "Can check file creation date" {
New-Item -ItemType Directory -Path "TestDrive:\MyFolder" -Force | Out-Null
$path = "TestDrive:\MyFolder\test.txt"
"hello" | Set-Content $path
(Get-Item $path).CreationTime | Should-BeAfter 1s -Ago
}
}
38 changes: 33 additions & 5 deletions tst/functions/assert/Time/Should-BeBefore.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ Describe "Should-BeBefore" {
}

It "Does not throw when actual date is before expected date using ago" {
[DateTime]::Now.AddMinutes(-11) | Should-BeBefore -TimeAgo 10minutes
[DateTime]::Now.AddMinutes(-11) | Should-BeBefore 10minutes -Ago
}

It "Does not throw when actual date is before expected date using fromNow" {
[datetime]::now.Add([timespan]::FromMinutes(-20)) | Should-BeBefore -TimeFromNow 10minutes
[DateTime]::Now.Add([timespan]::FromMinutes(-20)) | Should-BeBefore 10minutes -FromNow
}

It "Does not throw when actual date is before expected date using Now" {
[DateTime]::Now.Add([timespan]::FromMinutes(-20)) | Should-BeBefore -Now
}

It "Does not throw when actual date is before expected date using Now parameter set but not providing any switch" {
[DateTime]::Now.Add([timespan]::FromMinutes(-20)) | Should-BeBefore
}

It "Throws when actual date is after expected date" -ForEach @(
Expand All @@ -21,11 +29,31 @@ Describe "Should-BeBefore" {
{ $Actual | Should-BeBefore -Expected $Expected } | Verify-AssertionFailed
}

It "Throw when actual date is after expected date using ago" {
{ [DateTime]::Now.AddMinutes(-9) | Should-BeBefore -TimeAgo 10minutes } | Verify-AssertionFailed
It "Throws when actual date is after expected date using ago" {
{ [DateTime]::Now.AddMinutes(-9) | Should-BeBefore 10minutes -Ago } | Verify-AssertionFailed
}

It "Throws when actual date is after expected date using fromNow" {
{ [datetime]::now.Add([timespan]::FromMinutes(11)) | Should-BeBefore -TimeFromNow 10minutes } | Verify-AssertionFailed
{ [DateTime]::Now.Add([timespan]::FromMinutes(11)) | Should-BeBefore 10minutes -FromNow } | Verify-AssertionFailed
}

It "Throws when actual date is after expected date using Now" {
{ [DateTime]::Now.Add([timespan]::FromMinutes(20)) | Should-BeBefore -Now } | Verify-AssertionFailed
}

It "Throws when actual date is after expected date using Now parameter set but not providing any switch" {
{ [DateTime]::Now.Add([timespan]::FromMinutes(20)) | Should-BeBefore } | Verify-AssertionFailed
}

It "Throws when both -Ago and -FromNow are used" -ForEach @(
) {
{ $Actual | Should-BeBefore 10minutes -Ago -FromNow } | Verify-Throw
}

It "Can check file creation date" {
New-Item -ItemType Directory -Path "TestDrive:\MyFolder" -Force | Out-Null
$path = "TestDrive:\MyFolder\test.txt"
"hello" | Set-Content $path
(Get-Item $path).CreationTime | Should-BeBefore -Now
}
}