@@ -186,6 +186,70 @@ public async Task RunProfileCommandCreatesTheExpectedProfile_DefaultScenario()
186
186
profile . Monitors . Select ( a => a . Parameters [ "Scenario" ] . ToString ( ) ) ) ;
187
187
}
188
188
189
+ [ Test ]
190
+ public async Task RunProfileCommandAddsTheExpectedMetadataToProfile ( )
191
+ {
192
+ // Scenario:
193
+ // In the default scenario, a workload profile is supplied that only contains
194
+ // workloads (i.e. no specific monitors).
195
+ string profile1 = "TEST-WORKLOAD-PROFILE.json" ;
196
+ string defaultMonitorProfile = "MONITORS-DEFAULT.json" ;
197
+ List < string > profiles = new List < string > { this . mockFixture . GetProfilesPath ( profile1 ) } ;
198
+ this . command . Metadata = new Dictionary < string , IConvertible > ( ) ;
199
+ this . command . Metadata . Add ( "MetadataKey1" , "MetadataValue1" ) ;
200
+ this . command . Metadata . Add ( "MetadataKey2" , "MetadataValue2" ) ;
201
+
202
+ // Setup:
203
+ // Read the actual profile content from the local file system.
204
+ this . mockFixture . File
205
+ . Setup ( file => file . ReadAllTextAsync ( It . Is < string > ( file => file . EndsWith ( profile1 ) ) , It . IsAny < CancellationToken > ( ) ) )
206
+ . ReturnsAsync ( File . ReadAllText ( this . mockFixture . Combine ( RunProfileCommandTests . ProfilesDirectory , profile1 ) ) ) ;
207
+
208
+ this . mockFixture . File
209
+ . Setup ( file => file . ReadAllTextAsync ( It . Is < string > ( file => file . EndsWith ( defaultMonitorProfile ) ) , It . IsAny < CancellationToken > ( ) ) )
210
+ . ReturnsAsync ( File . ReadAllText ( this . mockFixture . Combine ( RunProfileCommandTests . ProfilesDirectory , defaultMonitorProfile ) ) ) ;
211
+
212
+ ExecutionProfile profile = await this . command . InitializeProfilesAsync ( profiles , this . mockFixture . Dependencies , CancellationToken . None )
213
+ . ConfigureAwait ( false ) ;
214
+
215
+ bool isCommandMetadataSubset = this . command . Metadata . All ( kvp =>
216
+ profile . Metadata . TryGetValue ( kvp . Key , out var value ) && value . Equals ( kvp . Value ) ) ;
217
+
218
+ Assert . IsTrue ( isCommandMetadataSubset ) ;
219
+ }
220
+
221
+ [ Test ]
222
+ public async Task RunProfileCommandAddsTheExpectedParametersToProfile ( )
223
+ {
224
+ // Scenario:
225
+ // In the default scenario, a workload profile is supplied that only contains
226
+ // workloads (i.e. no specific monitors).
227
+ string profile1 = "TEST-WORKLOAD-PROFILE.json" ;
228
+ string defaultMonitorProfile = "MONITORS-DEFAULT.json" ;
229
+ List < string > profiles = new List < string > { this . mockFixture . GetProfilesPath ( profile1 ) } ;
230
+ this . command . Parameters = new Dictionary < string , IConvertible > ( ) ;
231
+ this . command . Parameters . Add ( "ParameterKey1" , "ParameterValue1" ) ;
232
+ this . command . Parameters . Add ( "ParameterKey2" , "ParameterValue2" ) ;
233
+
234
+ // Setup:
235
+ // Read the actual profile content from the local file system.
236
+ this . mockFixture . File
237
+ . Setup ( file => file . ReadAllTextAsync ( It . Is < string > ( file => file . EndsWith ( profile1 ) ) , It . IsAny < CancellationToken > ( ) ) )
238
+ . ReturnsAsync ( File . ReadAllText ( this . mockFixture . Combine ( RunProfileCommandTests . ProfilesDirectory , profile1 ) ) ) ;
239
+
240
+ this . mockFixture . File
241
+ . Setup ( file => file . ReadAllTextAsync ( It . Is < string > ( file => file . EndsWith ( defaultMonitorProfile ) ) , It . IsAny < CancellationToken > ( ) ) )
242
+ . ReturnsAsync ( File . ReadAllText ( this . mockFixture . Combine ( RunProfileCommandTests . ProfilesDirectory , defaultMonitorProfile ) ) ) ;
243
+
244
+ ExecutionProfile profile = await this . command . InitializeProfilesAsync ( profiles , this . mockFixture . Dependencies , CancellationToken . None )
245
+ . ConfigureAwait ( false ) ;
246
+
247
+ bool isCommandParametersSubset = this . command . Parameters . All ( kvp =>
248
+ profile . Parameters . TryGetValue ( kvp . Key , out var value ) && value . Equals ( kvp . Value ) ) ;
249
+
250
+ Assert . IsTrue ( isCommandParametersSubset ) ;
251
+ }
252
+
189
253
[ Test ]
190
254
public async Task RunProfileCommandCreatesTheExpectedProfile_DefaultMonitorProfileExplicitlyDefinedScenario ( )
191
255
{
0 commit comments