diff --git a/Tasks/build.ps1 b/Tasks/build.ps1 index e69d7e7..fffc786 100644 --- a/Tasks/build.ps1 +++ b/Tasks/build.ps1 @@ -1,16 +1,10 @@ [CmdletBinding()] param( - [switch] - $Bootstrap, - [switch] $Compile, [switch] - $Test, - - [switch] - $CodeCoverage + $Test ) # Write information @@ -30,28 +24,6 @@ Write-Host '' $RootDir = Join-Path $PSScriptRoot '..' $OutputDir = Join-Path $RootDir 'Output' -# Bootstrap step -if ($Bootstrap.IsPresent) { - Write-Information "Validate and install missing prerequisits for building ..." - - # For testing Pester - if (-not (Get-Module -Name Pester -ListAvailable) -or (Get-Module -Name Pester -ListAvailable)[0].Version -eq [Version]'3.4.0') { - Write-Warning "Module 'Pester' is missing. Installing 'Pester' ..." - Install-Module -Name Pester -Scope CurrentUser -Force -RequiredVersion 4.10.1 -SkipPublisherCheck - } - - if ((Get-Module -Name Pester -ListAvailable)[0].Version -ne [Version]'4.10.1') { - Install-Module -Name Pester -Scope CurrentUser -Force -RequiredVersion 4.10.1 - } - - Import-Module -Name Pester -RequiredVersion 4.10.1 - - if (-not (Get-Module -Name PSCodeCovIo -ListAvailable)) { - Write-Warning "Module 'PSCodeCovIo' is missing. Installing 'PSCodeCovIo' ..." - Install-Module -Name PSCodeCovIo -Scope CurrentUser -Force - } -} - # Compile step if ($Compile.IsPresent) { $CompileDir = Join-Path $OutputDir 'BurntToast' @@ -65,17 +37,17 @@ if ($Compile.IsPresent) { $null = New-Item -Path $CompileDir -ItemType Directory Write-Host "Copying support files ..." - Copy-Item -Path "$RootDir/BurntToast/*" -Filter '*.*' -Exclude '*.ps1', '*.psm1' -Recurse -Destination $CompileDir -Force + Copy-Item -Path "$RootDir/src/*" -Filter '*.*' -Exclude '*.ps1', '*.psm1' -Recurse -Destination $CompileDir -Force Remove-Item -Path "$CompileDir/Private", "$CompileDir/Public" -Recurse -Force # Copy Module README file Copy-Item -Path "$RootDir/README.md" -Destination $CompileDir -Force Write-Host "Adding Private Functions ..." - Get-ChildItem -Path "$RootDir\BurntToast\Private\*.ps1" -Recurse | Get-Content | Add-Content "$CompileDir/BurntToast.psm1" + Get-ChildItem -Path "$RootDir/src/Private/*.ps1" -Recurse | Get-Content | Add-Content "$CompileDir/BurntToast.psm1" Write-Host "Adding Public Functions ..." - $Public = @( Get-ChildItem -Path "$RootDir/BurntToast/Public/*.ps1" -ErrorAction SilentlyContinue ) + $Public = @( Get-ChildItem -Path "$RootDir/src/Public/*.ps1" -ErrorAction SilentlyContinue ) $Public | Get-Content | Add-Content "$CompileDir/BurntToast.psm1" @@ -102,34 +74,25 @@ if ($Compile.IsPresent) { # Test step if ($Test.IsPresent) { - if (-not (Get-Module -Name Pester -ListAvailable)) { - throw "Cannot find the 'Pester' module. Please specify '-Bootstrap' to install build dependencies." - } - - if (-not (Get-Module -Name PSCodeCovIo -ListAvailable)) { - throw "Cannot find the 'PSCodeCovIo' module. Please specify '-Bootstrap' to install build dependencies." - } + Write-Host "Running Pester within CI with code coverage" - if ($ENV:BURNTTOAST_MODULE_ROOT) { - $ModuleDir = (Get-Item -Path $ENV:BURNTTOAST_MODULE_ROOT).Directory.FullName - Write-Host "Using Module Root directory of $ModuleDir" - $RelevantFiles = (Get-ChildItem $ModuleDir -Recurse -Include "*.psm1", "*.ps1").FullName - } else { - $RelevantFiles = (Get-ChildItem ./BurntToast -Recurse -Include "*.psm1", "*.ps1").FullName - } + $PesterConfig = New-PesterConfiguration - if ($env:CI) { - Write-Host "Running Pester within CI with code coverage for $($RelevantFiles.Count) file/s" - $res = Invoke-Pester "./Tests" -OutputFormat JUnitXml -OutputFile TestResults.xml -CodeCoverage $RelevantFiles -CodeCoverageOutputFileFormat 'JaCoCo' -CodeCoverageOutputFile CoverageResults.xml -PassThru - if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed." } - } - else { - $res = Invoke-Pester "./Tests" -CodeCoverage $RelevantFiles -PassThru - } + $PesterConfig.Run.Path = './tests' + $PesterConfig.Run.PassThru = $true - if ($CodeCoverage.IsPresent) { - Export-CodeCovIoJson -CodeCoverage $res.CodeCoverage -RepoRoot $pwd -Path coverage.json + $PesterConfig.TestResult.Enabled = $true + $PesterConfig.TestResult.OutputFormat = 'JUnitXml' + $PesterConfig.TestResult.OutputPath = 'TestResults.xml' - Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh + if ($null -eq $ENV:BURNTTOAST_MODULE_ROOT) { + $PesterConfig.CodeCoverage.Enabled = $true + $PesterConfig.CodeCoverage.OutputFormat = 'JaCoCo' + $PesterConfig.CodeCoverage.OutputPath = 'CoverageResults.xml' + $PesterConfig.CodeCoverage.Path = './src' + $PesterConfig.CodeCoverage.RecursePaths = $true } + + $res = Invoke-Pester -Configuration $PesterConfig + if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed." } } diff --git a/Tests/BurntToast.Tests.ps1 b/Tests/BurntToast.Tests.ps1 index 2ef79a3..6905d06 100644 --- a/Tests/BurntToast.Tests.ps1 +++ b/Tests/BurntToast.Tests.ps1 @@ -1,13 +1,58 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'BurntToast Module' { Context 'meta validation' { It 'should import functions' { - (Get-Module BurntToast).ExportedFunctions.Count | Should -Be 25 + (Get-Module BurntToast).ExportedFunctions.Count | Should -Be 21 } 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 + } + } } diff --git a/Tests/Get-BTHeader.Tests.ps1 b/Tests/Get-BTHeader.Tests.ps1 index dc3ef79..e7142a1 100644 --- a/Tests/Get-BTHeader.Tests.ps1 +++ b/Tests/Get-BTHeader.Tests.ps1 @@ -1,14 +1,21 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') - -# Helper function needs to be in the global scope so it can be used in mocks -# Note - This may not work in Pester 5+ -Function Global:New-MockNotification( - $HeaderId = (New-GUID).ToString(), - $HeaderTitle = (New-GUID).ToString(), - $HeaderArguments = '', - $HeaderActivation = 'protocol' - ) { - $Content = @" +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } + + Function Global:New-MockNotification( + $HeaderId = (New-GUID).ToString(), + $HeaderTitle = (New-GUID).ToString(), + $HeaderArguments = '', + $HeaderActivation = 'protocol' + ) { + $Content = @" @@ -20,9 +27,10 @@ Function Global:New-MockNotification(
"@ - $XMLContent = [Windows.Data.Xml.Dom.XmlDocument]::new() - $XmlContent.LoadXml($Content) - [Windows.UI.Notifications.ToastNotification]::new($XMLContent) + $XMLContent = [Windows.Data.Xml.Dom.XmlDocument]::new() + $XmlContent.LoadXml($Content) + [Windows.UI.Notifications.ToastNotification]::new($XMLContent) + } } Describe 'Get-BTHeader' { diff --git a/Tests/Get-BTHistory.Tests.ps1 b/Tests/Get-BTHistory.Tests.ps1 index 0ae3dbc..908caff 100644 --- a/Tests/Get-BTHistory.Tests.ps1 +++ b/Tests/Get-BTHistory.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'Get-BTHistory' { if ($PlatformAvailable) { diff --git a/Tests/New-BTAction.Tests.ps1 b/Tests/New-BTAction.Tests.ps1 index 60b462e..b02eda1 100644 --- a/Tests/New-BTAction.Tests.ps1 +++ b/Tests/New-BTAction.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTAction' { Context 'running without arguments' { diff --git a/Tests/New-BTAppId.Tests.ps1 b/Tests/New-BTAppId.Tests.ps1 index 62d952b..24c2fb3 100644 --- a/Tests/New-BTAppId.Tests.ps1 +++ b/Tests/New-BTAppId.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTAppId' { Mock New-Item {} -ModuleName BurntToast diff --git a/Tests/New-BTAudio.Tests.ps1 b/Tests/New-BTAudio.Tests.ps1 index d09bf63..35128d0 100644 --- a/Tests/New-BTAudio.Tests.ps1 +++ b/Tests/New-BTAudio.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTAudio' { Context 'built in audio source' { diff --git a/Tests/New-BTBinding.Tests.ps1 b/Tests/New-BTBinding.Tests.ps1 index 851c0aa..1a16353 100644 --- a/Tests/New-BTBinding.Tests.ps1 +++ b/Tests/New-BTBinding.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTBinding' { Context 'loaded with children' { diff --git a/Tests/New-BTButton.Tests.ps1 b/Tests/New-BTButton.Tests.ps1 index e262f2b..08159be 100644 --- a/Tests/New-BTButton.Tests.ps1 +++ b/Tests/New-BTButton.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTButton' { Context 'system defined dismiss button' { diff --git a/Tests/New-BTColumn.Tests.ps1 b/Tests/New-BTColumn.Tests.ps1 index 26a72c6..de8a3a6 100644 --- a/Tests/New-BTColumn.Tests.ps1 +++ b/Tests/New-BTColumn.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTColumn' { Context 'via New-BurntToastNotification' { diff --git a/Tests/New-BTContent.Tests.ps1 b/Tests/New-BTContent.Tests.ps1 index 50634e2..320c685 100644 --- a/Tests/New-BTContent.Tests.ps1 +++ b/Tests/New-BTContent.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTContent' { $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName diff --git a/Tests/New-BTContextMenuItem.Tests.ps1 b/Tests/New-BTContextMenuItem.Tests.ps1 index 7d9f3c0..684e6b2 100644 --- a/Tests/New-BTContextMenuItem.Tests.ps1 +++ b/Tests/New-BTContextMenuItem.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTContextMenuItem' { Context 'loaded with standard arguments' { diff --git a/Tests/New-BTHeader.Tests.ps1 b/Tests/New-BTHeader.Tests.ps1 index 7e44bcc..747d634 100644 --- a/Tests/New-BTHeader.Tests.ps1 +++ b/Tests/New-BTHeader.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTHeader' { Context 'loaded with standard arguments' { diff --git a/Tests/New-BTImage.Tests.ps1 b/Tests/New-BTImage.Tests.ps1 index b6f9a07..1e0d21a 100644 --- a/Tests/New-BTImage.Tests.ps1 +++ b/Tests/New-BTImage.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTImage' { $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName diff --git a/Tests/New-BTInput.Tests.ps1 b/Tests/New-BTInput.Tests.ps1 index 2faf1df..70f0606 100644 --- a/Tests/New-BTInput.Tests.ps1 +++ b/Tests/New-BTInput.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTInput' { Context 'text entry box' { diff --git a/Tests/New-BTProgressBar.Tests.ps1 b/Tests/New-BTProgressBar.Tests.ps1 index c13c8ae..2fd4370 100644 --- a/Tests/New-BTProgressBar.Tests.ps1 +++ b/Tests/New-BTProgressBar.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTProgressBar' { Context 'fixed value and status' { diff --git a/Tests/New-BTSelectionBoxItem.Tests.ps1 b/Tests/New-BTSelectionBoxItem.Tests.ps1 index 7d5514b..5cd3e1d 100644 --- a/Tests/New-BTSelectionBoxItem.Tests.ps1 +++ b/Tests/New-BTSelectionBoxItem.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTSelectionBoxItem' { Context 'loaded with standard arguments' { diff --git a/Tests/New-BTText.Tests.ps1 b/Tests/New-BTText.Tests.ps1 index c3999fa..beba993 100644 --- a/Tests/New-BTText.Tests.ps1 +++ b/Tests/New-BTText.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTText' { Context 'blank line' { diff --git a/Tests/New-BTVisual.Tests.ps1 b/Tests/New-BTVisual.Tests.ps1 index 395224f..a6b3fd7 100644 --- a/Tests/New-BTVisual.Tests.ps1 +++ b/Tests/New-BTVisual.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTVisual' { $Text1 = New-BTText -Content 'This is a test' diff --git a/Tests/New-BurntToastNotification.Tests.ps1 b/Tests/New-BurntToastNotification.Tests.ps1 index be60da6..5f309de 100644 --- a/Tests/New-BurntToastNotification.Tests.ps1 +++ b/Tests/New-BurntToastNotification.Tests.ps1 @@ -1,4 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BurntToastNotification' { $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName diff --git a/Tests/_envPrep.ps1 b/Tests/_envPrep.ps1 deleted file mode 100644 index 259b42c..0000000 --- a/Tests/_envPrep.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -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 -} - -if ($ENV:BURNTTOAST_MODULE_ROOT) { - Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force -} else { - Import-Module "$PSScriptRoot/../BurntToast/BurntToast.psd1" -Force -} - diff --git a/Tests/_pester.ps1 b/Tests/_pester.ps1 new file mode 100644 index 0000000..ecd39bf --- /dev/null +++ b/Tests/_pester.ps1 @@ -0,0 +1,4 @@ +$PesterResult = Invoke-Pester -PassThru +if ($PesterResult.FailedCount -ne 0) { + throw "There were $($PesterResult.FailedCount) failed tests." +} \ No newline at end of file diff --git a/Tests/_pssa.ps1 b/Tests/_pssa.ps1 new file mode 100644 index 0000000..3e7e19c --- /dev/null +++ b/Tests/_pssa.ps1 @@ -0,0 +1,12 @@ +$ExcludedRules = @() + +$PssaSplat = @{ + Path = ".\src" + Recurse = $true + EnableExit = $true + ReportSummary = $true + ExcludeRule = $ExcludedRules + #Severity = 'Error' +} + +Invoke-ScriptAnalyzer @PssaSplat