@@ -52,8 +52,23 @@ public void SetupDefaults()
52
52
"VirtualClient.TestExecutor" ,
53
53
new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario2" } ) ,
54
54
new ExecutionProfileElement (
55
- "VirtualClient.TestExecutor" ,
56
- new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario3" } )
55
+ "VirtualClient.TestCollectionExecutor" ,
56
+ new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario3" } ,
57
+ components : new List < ExecutionProfileElement > ( )
58
+ {
59
+ new ExecutionProfileElement (
60
+ "VirtualClient.TestExecutor" ,
61
+ new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario1" } ) ,
62
+ new ExecutionProfileElement (
63
+ "VirtualClient.TestExecutor" ,
64
+ new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario2" } ) ,
65
+ new ExecutionProfileElement (
66
+ "VirtualClient.TestExecutor" ,
67
+ new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario3" } ) ,
68
+ new ExecutionProfileElement (
69
+ "VirtualClient.TestExecutor" ,
70
+ new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario4" } )
71
+ } )
57
72
} ,
58
73
dependencies : new List < ExecutionProfileElement >
59
74
{
@@ -94,7 +109,8 @@ public void ProfileExecutorCreatesTheExpectedWorkloadActionExecutorsAsDefinedInT
94
109
95
110
Assert . IsNotEmpty ( executor . ProfileActions ) ;
96
111
Assert . IsTrue ( executor . ProfileActions . Count ( ) == 3 ) ;
97
- Assert . IsTrue ( executor . ProfileActions . All ( action => action . GetType ( ) == typeof ( TestExecutor ) ) ) ;
112
+ Assert . IsTrue ( executor . ProfileActions . Where ( action => action . GetType ( ) == typeof ( TestExecutor ) ) . Count ( ) == 2 ) ;
113
+ Assert . IsTrue ( executor . ProfileActions . Where ( action => action . GetType ( ) == typeof ( TestCollectionExecutor ) ) . Count ( ) == 1 ) ;
98
114
Assert . AreEqual ( "Scenario1" , executor . ProfileActions . ElementAt ( 0 ) . Parameters [ "Scenario" ] ) ;
99
115
Assert . AreEqual ( "Scenario2" , executor . ProfileActions . ElementAt ( 1 ) . Parameters [ "Scenario" ] ) ;
100
116
Assert . AreEqual ( "Scenario3" , executor . ProfileActions . ElementAt ( 2 ) . Parameters [ "Scenario" ] ) ;
@@ -208,6 +224,12 @@ public void ProfileExecutorSupportsUserSpecifiedScenarios_Subsets_Of_Scenarios()
208
224
CollectionAssert . AreEquivalent (
209
225
this . mockProfile . Actions . Skip ( 1 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
210
226
executor . ProfileActions . Select ( a => a . Parameters [ "Scenario" ] ) ) ;
227
+
228
+ // Assert child components honor the scenario values.
229
+ VirtualClientComponentCollection collectionComponent = executor . ProfileActions . First ( action => action . GetType ( ) == typeof ( TestCollectionExecutor ) ) as VirtualClientComponentCollection ;
230
+ Assert . IsNotNull ( collectionComponent ) ;
231
+ Assert . AreEqual ( 2 , collectionComponent . Count ) ;
232
+ Assert . IsTrue ( collectionComponent . All ( component => targetScenarios . Contains ( component . Parameters [ "Scenario" ] ) ) ) ;
211
233
}
212
234
}
213
235
@@ -220,18 +242,25 @@ public void ProfileExecutorSupportsUserSpecifiedScenarios_Components_Have_Duplic
220
242
} ;
221
243
222
244
// Ensure we have components that share the same scenario name.
223
- this . mockProfile . Actions . Take ( 2 ) . ToList ( ) . ForEach ( a => a . Parameters [ "Scenario" ] = "Scenario1" ) ;
245
+ this . mockProfile . Actions . Take ( 3 ) . ToList ( ) . ForEach ( a => a . Parameters [ "Scenario" ] = "Scenario1" ) ;
246
+ this . mockProfile . Actions . Last ( ) . Components . ToList ( ) . ForEach ( a => a . Parameters [ "Scenario" ] = "Scenario1" ) ;
224
247
225
248
using ( TestProfileExecutor executor = new TestProfileExecutor ( this . mockProfile , this . mockFixture . Dependencies , targetScenarios ) )
226
249
{
227
250
executor . Initialize ( ) ;
228
251
229
252
Assert . IsNotEmpty ( executor . ProfileActions ) ;
230
- Assert . IsTrue ( executor . ProfileActions . Count ( ) == 2 ) ;
253
+ Assert . IsTrue ( executor . ProfileActions . Count ( ) == 3 ) ;
231
254
232
255
CollectionAssert . AreEquivalent (
233
- this . mockProfile . Actions . Take ( 2 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
256
+ this . mockProfile . Actions . Take ( 3 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
234
257
executor . ProfileActions . Select ( a => a . Parameters [ "Scenario" ] ) ) ;
258
+
259
+ // Assert child components honor the scenario values.
260
+ VirtualClientComponentCollection collectionComponent = executor . ProfileActions . First ( action => action . GetType ( ) == typeof ( TestCollectionExecutor ) ) as VirtualClientComponentCollection ;
261
+ Assert . IsNotNull ( collectionComponent ) ;
262
+ Assert . AreEqual ( 4 , collectionComponent . Count ) ;
263
+ Assert . IsTrue ( collectionComponent . All ( component => targetScenarios . Contains ( component . Parameters [ "Scenario" ] ) ) ) ;
235
264
}
236
265
}
237
266
@@ -273,6 +302,92 @@ public void ProfileExecutorSupportsUserSpecifiedScenarioExclusionForActions()
273
302
}
274
303
}
275
304
305
+ [ Test ]
306
+ public void ProfileExecutorSupportsUserSpecifiedScenarioExclusionForActionsAndChildComponents ( )
307
+ {
308
+ List < string > excludedScenarios = new List < string > ( )
309
+ {
310
+ "-Scenario1" ,
311
+ "-Scenario2"
312
+ } ;
313
+
314
+ using ( TestProfileExecutor executor = new TestProfileExecutor ( this . mockProfile , this . mockFixture . Dependencies , excludedScenarios ) )
315
+ {
316
+ executor . Initialize ( ) ;
317
+
318
+ Assert . IsNotEmpty ( executor . ProfileActions ) ;
319
+ Assert . IsTrue ( executor . ProfileActions . Count ( ) == 1 ) ;
320
+
321
+ CollectionAssert . AreEquivalent (
322
+ this . mockProfile . Actions . Skip ( 2 ) . Take ( 1 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
323
+ executor . ProfileActions . Select ( a => a . Parameters [ "Scenario" ] ) ) ;
324
+
325
+ // Assert child components honor the scenario values.
326
+ VirtualClientComponentCollection collectionComponent = executor . ProfileActions . First ( action => action . GetType ( ) == typeof ( TestCollectionExecutor ) ) as VirtualClientComponentCollection ;
327
+ Assert . IsNotNull ( collectionComponent ) ;
328
+ Assert . AreEqual ( 2 , collectionComponent . Count ) ;
329
+
330
+ Assert . IsTrue ( collectionComponent . First ( ) . Parameters [ "Scenario" ] . ToString ( ) == "Scenario3" ) ;
331
+ Assert . IsTrue ( collectionComponent . Last ( ) . Parameters [ "Scenario" ] . ToString ( ) == "Scenario4" ) ;
332
+ }
333
+ }
334
+
335
+ [ Test ]
336
+ public void ProfileExecutorSupportsUsingSpecifiedInclusionsForSpecificChildComponents ( )
337
+ {
338
+ List < string > includedScenarios = new List < string > ( )
339
+ {
340
+ "Scenario3" ,
341
+ "Scenario4"
342
+ } ;
343
+
344
+ using ( TestProfileExecutor executor = new TestProfileExecutor ( this . mockProfile , this . mockFixture . Dependencies , includedScenarios ) )
345
+ {
346
+ executor . Initialize ( ) ;
347
+
348
+ Assert . IsNotEmpty ( executor . ProfileActions ) ;
349
+ Assert . IsTrue ( executor . ProfileActions . Count ( ) == 1 ) ;
350
+
351
+ CollectionAssert . AreEquivalent (
352
+ this . mockProfile . Actions . Skip ( 2 ) . Take ( 1 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
353
+ executor . ProfileActions . Select ( a => a . Parameters [ "Scenario" ] ) ) ;
354
+
355
+ // Assert child components honor the scenario values.
356
+ VirtualClientComponentCollection collectionComponent = executor . ProfileActions . First ( action => action . GetType ( ) == typeof ( TestCollectionExecutor ) ) as VirtualClientComponentCollection ;
357
+ Assert . IsNotNull ( collectionComponent ) ;
358
+ Assert . AreEqual ( 2 , collectionComponent . Count ) ;
359
+
360
+ Assert . IsTrue ( collectionComponent . First ( ) . Parameters [ "Scenario" ] . ToString ( ) == "Scenario3" ) ;
361
+ Assert . IsTrue ( collectionComponent . Last ( ) . Parameters [ "Scenario" ] . ToString ( ) == "Scenario4" ) ;
362
+ }
363
+ }
364
+
365
+ [ Test ]
366
+ public void ProfileExecutorSupportsUsingSpecifiedExclusionsForSpecificChildComponents ( )
367
+ {
368
+ List < string > includedScenarios = new List < string > ( )
369
+ {
370
+ "-Scenario4"
371
+ } ;
372
+
373
+ this . mockProfile . Actions . Last ( ) . Parameters . Remove ( "Scenario" ) ;
374
+
375
+ using ( TestProfileExecutor executor = new TestProfileExecutor ( this . mockProfile , this . mockFixture . Dependencies , includedScenarios ) )
376
+ {
377
+ executor . Initialize ( ) ;
378
+
379
+ Assert . IsNotEmpty ( executor . ProfileActions ) ;
380
+ Assert . IsTrue ( executor . ProfileActions . Count ( ) == 3 ) ;
381
+
382
+ // Assert child components honor the scenario values.
383
+ VirtualClientComponentCollection collectionComponent = executor . ProfileActions . First ( action => action . GetType ( ) == typeof ( TestCollectionExecutor ) ) as VirtualClientComponentCollection ;
384
+ Assert . IsNotNull ( collectionComponent ) ;
385
+ Assert . AreEqual ( 3 , collectionComponent . Count ) ;
386
+
387
+ Assert . IsTrue ( collectionComponent . All ( component => component . Parameters [ "Scenario" ] . ToString ( ) != "Scenario4" ) ) ;
388
+ }
389
+ }
390
+
276
391
[ Test ]
277
392
public void ProfileExecutorSupportsUserSpecifiedScenarioExclusionForDependencies ( )
278
393
{
@@ -554,11 +669,17 @@ public async Task ProfileExecutorCorrelationIdentifiersAreCorrectForActionsExecu
554
669
Assert . IsNotEmpty ( iterations ) ;
555
670
Assert . IsTrue ( iterations . Count ( ) == 2 ) ;
556
671
557
- var actions = this . mockFixture . Logger . Where ( log => log . Item2 . Name == "TestExecutor.ExecuteStart" ) . Select ( a => a . Item3 as EventContext ) ;
558
- Assert . IsNotNull ( actions ) ;
559
- Assert . IsNotEmpty ( actions ) ;
560
- Assert . IsTrue ( actions . Count ( ) == 6 ) ;
672
+ var singleActions = this . mockFixture . Logger . Where ( log => log . Item2 . Name == "TestExecutor.ExecuteStart" ) . Select ( a => a . Item3 as EventContext ) ;
673
+ Assert . IsNotNull ( singleActions ) ;
674
+ Assert . IsNotEmpty ( singleActions ) ;
675
+ Assert . AreEqual ( 4 , singleActions . Count ( ) ) ;
676
+
677
+ var collectionActions = this . mockFixture . Logger . Where ( log => log . Item2 . Name == "TestCollectionExecutor.ExecuteStart" ) . Select ( a => a . Item3 as EventContext ) ;
678
+ Assert . IsNotNull ( collectionActions ) ;
679
+ Assert . IsNotEmpty ( collectionActions ) ;
680
+ Assert . AreEqual ( 2 , collectionActions . Count ( ) ) ;
561
681
682
+ var actions = singleActions . Union ( collectionActions ) ;
562
683
// First round of actions should have the same parent ID but each action should have its
563
684
// own unique activity ID.
564
685
var iteration1Actions = actions . Where ( a => a . ParentActivityId == iterations . ElementAt ( 0 ) . ActivityId ) ;
0 commit comments