File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22Describe " Set-BloggerConfig" {
33 BeforeEach {
44 Import-Module $PSScriptRoot \..\PSBlogger.psm1 - Force
5+
6+ # Ensure the test has a clean BloggerSession variable
57 InModuleScope " PSBlogger" {
8+ # Remove the existing variable if it exists
9+ if (Get-Variable - Name BloggerSession - Scope Script - ErrorAction SilentlyContinue) {
10+ Remove-Variable - Name BloggerSession - Scope Script - Force
11+ }
12+
13+ # Create a new test-specific BloggerSession
614 $BloggerSession = [pscustomobject ]@ {
715 BlogId = $null
816 UserPreferences = " TestDrive:\UserPreferences.json"
917 }
18+
19+ # Set it as a script-scoped variable (same as the module does)
20+ New-Variable - Name BloggerSession - Value $BloggerSession - Scope Script - Force
1021 }
1122 }
1223
1324 It " Should persist new value to <UserPreference> to BloggerSession.UserPreferences" - TestCases @ (
1425 @ { UserPreference = " BlogId" ; UserPreferenceValue = " 12345" }
1526 ) {
16- # arrange
17- InModuleScope " PSBlogger" {
18- $BloggerSession = [pscustomobject ]@ {
19- BlogId = $null
20- UserPreferences = " TestDrive:\UserPreferences.json"
21- }
22- }
2327
2428 # act
2529 Set-BloggerConfig - Name $UserPreference - Value $UserPreferenceValue - ErrorAction Stop
You can’t perform that action at this time.
0 commit comments