@@ -110,37 +110,34 @@ public async Task CanCancelExecutionWithMethod()
110
110
[ Fact ]
111
111
public async Task CanResolveAndLoadProfilesForHostId ( )
112
112
{
113
- string [ ] expectedProfilePaths =
114
- new string [ ]
115
- {
116
- PsesHostFactory . TestProfilePaths . AllUsersAllHosts ,
117
- PsesHostFactory . TestProfilePaths . AllUsersCurrentHost ,
118
- PsesHostFactory . TestProfilePaths . CurrentUserAllHosts ,
119
- PsesHostFactory . TestProfilePaths . CurrentUserCurrentHost
120
- } ;
121
-
122
113
// Load the profiles for the test host name
123
114
await psesHost . LoadHostProfilesAsync ( CancellationToken . None ) . ConfigureAwait ( true ) ;
124
115
125
- // Ensure that all the paths are set in the correct variables
126
- // and that the current user's host profile got loaded
127
- PSCommand psCommand = new PSCommand ( ) . AddScript (
128
- "\" $($profile.AllUsersAllHosts) " +
129
- "$($profile.AllUsersCurrentHost) " +
130
- "$($profile.CurrentUserAllHosts) " +
131
- "$($profile.CurrentUserCurrentHost) " +
132
- "$(Assert-ProfileLoaded)\" " ) ;
133
-
134
- IReadOnlyList < string > result = await psesHost . ExecutePSCommandAsync < string > ( psCommand , CancellationToken . None ) . ConfigureAwait ( true ) ;
135
-
136
- string expectedString =
137
- string . Format (
138
- "{0} True" ,
139
- string . Join (
140
- " " ,
141
- expectedProfilePaths ) ) ;
142
-
143
- Assert . Equal ( expectedString , result [ 0 ] , ignoreCase : true ) ;
116
+ // Ensure that the $PROFILE variable is a string with the value of CurrentUserCurrentHost.
117
+ IReadOnlyList < string > profileVariable = await psesHost . ExecutePSCommandAsync < string > (
118
+ new PSCommand ( ) . AddScript ( "$PROFILE" ) ,
119
+ CancellationToken . None ) . ConfigureAwait ( true ) ;
120
+
121
+ Assert . Collection ( profileVariable ,
122
+ ( p ) => Assert . Equal ( PsesHostFactory . TestProfilePaths . CurrentUserCurrentHost , p ) ) ;
123
+
124
+ // Ensure that all the profile paths are set in the correct note properties.
125
+ IReadOnlyList < string > profileProperties = await psesHost . ExecutePSCommandAsync < string > (
126
+ new PSCommand ( ) . AddScript ( "$PROFILE | Get-Member -Type NoteProperty" ) ,
127
+ CancellationToken . None ) . ConfigureAwait ( true ) ;
128
+
129
+ Assert . Collection ( profileProperties ,
130
+ ( p ) => Assert . Equal ( $ "string AllUsersAllHosts={ PsesHostFactory . TestProfilePaths . AllUsersAllHosts } ", p , ignoreCase : true ) ,
131
+ ( p ) => Assert . Equal ( $ "string AllUsersCurrentHost={ PsesHostFactory . TestProfilePaths . AllUsersCurrentHost } ", p , ignoreCase : true ) ,
132
+ ( p ) => Assert . Equal ( $ "string CurrentUserAllHosts={ PsesHostFactory . TestProfilePaths . CurrentUserAllHosts } ", p , ignoreCase : true ) ,
133
+ ( p ) => Assert . Equal ( $ "string CurrentUserCurrentHost={ PsesHostFactory . TestProfilePaths . CurrentUserCurrentHost } ", p , ignoreCase : true ) ) ;
134
+
135
+ // Ensure that the profile was loaded. The profile also checks that $PROFILE was defined.
136
+ IReadOnlyList < bool > profileLoaded = await psesHost . ExecutePSCommandAsync < bool > (
137
+ new PSCommand ( ) . AddScript ( "Assert-ProfileLoaded" ) ,
138
+ CancellationToken . None ) . ConfigureAwait ( true ) ;
139
+
140
+ Assert . Collection ( profileLoaded , ( p ) => Assert . True ( p ) ) ;
144
141
}
145
142
146
143
[ Fact ]
0 commit comments