-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
68 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
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,58 @@ | ||
Describe 'BurntToast Module' { | ||
Context 'Importing on Supported Operating System' { | ||
It 'doesn''t throw' { | ||
if (Get-Module -Name 'BurntToast') { | ||
Remove-Module -Name 'BurntToast' | ||
} | ||
|
||
if ($ENV:BURNTTOAST_MODULE_ROOT) { | ||
{Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force} | Should -Not -Throw | ||
} else { | ||
{Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force} | Should -Not -Throw | ||
} | ||
} | ||
|
||
It 'should import functions' { | ||
(Get-Module BurntToast).ExportedFunctions.Count | Should -Be 6 | ||
} | ||
|
||
It 'should import aliases' { | ||
(Get-Module BurntToast).ExportedAliases.Count | Should -Be 1 | ||
} | ||
} | ||
|
||
Context 'Importing on Unsupported Operating Systems' { | ||
It 'throws when importing on operating systems older than Windows 10' { | ||
$env:BurntToastPesterNotWindows10 = $true | ||
|
||
if (Get-Module -Name 'BurntToast') { | ||
Remove-Module -Name 'BurntToast' | ||
} | ||
|
||
if ($ENV:BURNTTOAST_MODULE_ROOT) { | ||
{Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10.*' | ||
} else { | ||
{Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10.*' | ||
} | ||
} | ||
|
||
It 'throws when importing on Windows 10 builds older than the Anniversary Update' { | ||
$env:BurntToastPesterNotAnniversaryUpdate = $true | ||
|
||
if (Get-Module -Name 'BurntToast') { | ||
Remove-Module -Name 'BurntToast' | ||
} | ||
|
||
if ($ENV:BURNTTOAST_MODULE_ROOT) { | ||
{Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10 Creators Update (15063) and above.*' | ||
} else { | ||
{Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10 Creators Update (15063) and above.*' | ||
} | ||
} | ||
|
||
AfterEach { | ||
$env:BurntToastPesterNotWindows10 = $null | ||
$env:BurntToastPesterNotAnniversaryUpdate = $null | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,17 +1,9 @@ | ||
if (Get-Module -Name 'BurntToast') { | ||
Remove-Module -Name 'BurntToast' -Force | ||
} | ||
|
||
try { | ||
[Windows.UI.Notifications.ToastNotificationManager]::History.Clear('{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe') | ||
$PlatformAvailable = $true | ||
} catch { | ||
$PlatformAvailable = $false | ||
Remove-Module -Name 'BurntToast' | ||
} | ||
|
||
if ($ENV:BURNTTOAST_MODULE_ROOT) { | ||
Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force | ||
} else { | ||
Import-Module "$PSScriptRoot/../BurntToast/BurntToast.psd1" -Force | ||
} | ||
|
||
Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force | ||
} |
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,4 @@ | ||
$PesterResult = Invoke-Pester -PassThru | ||
if ($PesterResult.FailedCount -ne 0) { | ||
throw "There were $($PesterResult.FailedCount) failed tests." | ||
} |
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,12 @@ | ||
$ExcludedRules = @() | ||
|
||
$PssaSplat = @{ | ||
Path = ".\src" | ||
Recurse = $true | ||
EnableExit = $true | ||
ReportSummary = $true | ||
ExcludeRule = $ExcludedRules | ||
#Severity = 'Error' | ||
} | ||
|
||
Invoke-ScriptAnalyzer @PssaSplat |