@@ -52,8 +52,23 @@ public void SetupDefaults()
5252 "VirtualClient.TestExecutor" ,
5353 new Dictionary < string , IConvertible > { [ "Scenario" ] = "Scenario2" } ) ,
5454 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+ } )
5772 } ,
5873 dependencies : new List < ExecutionProfileElement >
5974 {
@@ -94,7 +109,8 @@ public void ProfileExecutorCreatesTheExpectedWorkloadActionExecutorsAsDefinedInT
94109
95110 Assert . IsNotEmpty ( executor . ProfileActions ) ;
96111 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 ) ;
98114 Assert . AreEqual ( "Scenario1" , executor . ProfileActions . ElementAt ( 0 ) . Parameters [ "Scenario" ] ) ;
99115 Assert . AreEqual ( "Scenario2" , executor . ProfileActions . ElementAt ( 1 ) . Parameters [ "Scenario" ] ) ;
100116 Assert . AreEqual ( "Scenario3" , executor . ProfileActions . ElementAt ( 2 ) . Parameters [ "Scenario" ] ) ;
@@ -208,6 +224,12 @@ public void ProfileExecutorSupportsUserSpecifiedScenarios_Subsets_Of_Scenarios()
208224 CollectionAssert . AreEquivalent (
209225 this . mockProfile . Actions . Skip ( 1 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
210226 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" ] ) ) ) ;
211233 }
212234 }
213235
@@ -220,18 +242,25 @@ public void ProfileExecutorSupportsUserSpecifiedScenarios_Components_Have_Duplic
220242 } ;
221243
222244 // 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" ) ;
224247
225248 using ( TestProfileExecutor executor = new TestProfileExecutor ( this . mockProfile , this . mockFixture . Dependencies , targetScenarios ) )
226249 {
227250 executor . Initialize ( ) ;
228251
229252 Assert . IsNotEmpty ( executor . ProfileActions ) ;
230- Assert . IsTrue ( executor . ProfileActions . Count ( ) == 2 ) ;
253+ Assert . IsTrue ( executor . ProfileActions . Count ( ) == 3 ) ;
231254
232255 CollectionAssert . AreEquivalent (
233- this . mockProfile . Actions . Take ( 2 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
256+ this . mockProfile . Actions . Take ( 3 ) . Select ( a => a . Parameters [ "Scenario" ] ) ,
234257 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" ] ) ) ) ;
235264 }
236265 }
237266
@@ -273,6 +302,92 @@ public void ProfileExecutorSupportsUserSpecifiedScenarioExclusionForActions()
273302 }
274303 }
275304
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+
276391 [ Test ]
277392 public void ProfileExecutorSupportsUserSpecifiedScenarioExclusionForDependencies ( )
278393 {
@@ -554,11 +669,17 @@ public async Task ProfileExecutorCorrelationIdentifiersAreCorrectForActionsExecu
554669 Assert . IsNotEmpty ( iterations ) ;
555670 Assert . IsTrue ( iterations . Count ( ) == 2 ) ;
556671
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 ( ) ) ;
561681
682+ var actions = singleActions . Union ( collectionActions ) ;
562683 // First round of actions should have the same parent ID but each action should have its
563684 // own unique activity ID.
564685 var iteration1Actions = actions . Where ( a => a . ParentActivityId == iterations . ElementAt ( 0 ) . ActivityId ) ;
0 commit comments