@@ -89,6 +89,7 @@ public void Should_Set_The_TestAdapter()
8989                    new  TestUserRunSettingsProjectDetails 
9090                    { 
9191                        CoverageOutputFolder  =  "" , 
92+                         TestDllFile  =  "" , 
9293                        Settings  =  new  TestMsCodeCoverageOptions {  IncludeTestAssembly  =  true } , 
9394                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
9495                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -116,6 +117,7 @@ public void Should_Set_The_ResultsDirectory_To_The_First_OutputFolder(string out
116117                    new  TestUserRunSettingsProjectDetails 
117118                    { 
118119                        CoverageOutputFolder  =  outputFolder1 , 
120+                         TestDllFile  =  "" , 
119121                        Settings  =  new  TestMsCodeCoverageOptions {  IncludeTestAssembly  =  true } , 
120122                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
121123                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -126,6 +128,7 @@ public void Should_Set_The_ResultsDirectory_To_The_First_OutputFolder(string out
126128                    new  TestUserRunSettingsProjectDetails 
127129                    { 
128130                        CoverageOutputFolder  =  outputFolder2 , 
131+                         TestDllFile  =  "" , 
129132                        Settings  =  new  TestMsCodeCoverageOptions {  IncludeTestAssembly  =  true } , 
130133                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
131134                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -157,7 +160,6 @@ TestMsCodeCoverageOptions CreateSettings(string id)
157160                return  new  TestMsCodeCoverageOptions 
158161                { 
159162                    IncludeTestAssembly  =  true , 
160- 
161163                    AttributesExclude  =  new  string [ ]  {  $ "AttributeExclude{ id } "  } , 
162164                    AttributesInclude  =  new  string [ ]  {  $ "AttributeInclude{ id } "  } , 
163165                    CompanyNamesExclude  =  new  string [ ]  {  $ "CompanyNameExclude{ id } "  } , 
@@ -178,6 +180,7 @@ TestMsCodeCoverageOptions CreateSettings(string id)
178180                    new  TestUserRunSettingsProjectDetails 
179181                    { 
180182                        CoverageOutputFolder  =  "" , 
183+                         TestDllFile  =  "" , 
181184                        Settings  =  CreateSettings ( "1" ) , 
182185                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
183186                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -188,6 +191,7 @@ TestMsCodeCoverageOptions CreateSettings(string id)
188191                    new  TestUserRunSettingsProjectDetails 
189192                    { 
190193                        CoverageOutputFolder  =  "" , 
194+                         TestDllFile  =  "" , 
191195                        Settings  =  CreateSettings ( "2" ) , 
192196                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
193197                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -276,8 +280,9 @@ string GetModulePathExcludeWhenExcludingTestAssembly(bool first)
276280            Assert . AreEqual ( expectedModulePathExcludes ,  replacements . ModulePathsExclude ) ; 
277281        } 
278282
279-         [ Test ] 
280-         public  void  Should_Add_Regexed_IncludedExcluded_Referenced_Projects_To_ModulePaths ( ) 
283+         [ TestCase ( true ) ] 
284+         [ TestCase ( false ) ] 
285+         public  void  Should_Add_Regexed_IncludedExcluded_Referenced_Projects_To_ModulePaths ( bool  included ) 
281286        { 
282287            var  testContainers  =  new  List < ITestContainer > ( ) 
283288            { 
@@ -290,48 +295,47 @@ public void Should_Add_Regexed_IncludedExcluded_Referenced_Projects_To_ModulePat
290295                { 
291296                    "Source1" , 
292297                    new  TestUserRunSettingsProjectDetails 
293-                     { 
294-                         CoverageOutputFolder  =  "" , 
295-                         Settings  =  new  TestMsCodeCoverageOptions { 
296-                             IncludeTestAssembly  =  true , 
297-                             ModulePathsExclude  =  new  string [ ] {  "ModulePathExclude" } , 
298-                             ModulePathsInclude  =  new  string [ ] {  "ModulePathInclude" } 
299-                         } , 
300-                         ExcludedReferencedProjects  =  new  List < string > {  "ExcludedReferenced1" } , 
301-                         IncludedReferencedProjects  =  new  List < string > {  "IncludedReferenced1"  } , 
302-                     } 
298+             { 
299+                 CoverageOutputFolder  =  "" , 
300+                 TestDllFile  =  "" , 
301+                 Settings  =  new  TestMsCodeCoverageOptions 
302+                 { 
303+                     IncludeTestAssembly  =  ! included , 
304+                     ModulePathsExclude  =  new  string [ ]  {  "ModulePathExclude"  } , 
305+                     ModulePathsInclude  =  new  string [ ]  {  "ModulePathInclude"  } 
306+                 } , 
307+                 ExcludedReferencedProjects  =  new  List < string >  {  "ExcludedReferenced1"  } , 
308+                 IncludedReferencedProjects  =  new  List < string >  {  "IncludedReferenced1"  } , 
309+             } 
303310                } , 
304311                { 
305312                    "Source2" , 
306313                    new  TestUserRunSettingsProjectDetails 
307314                    { 
308315                        CoverageOutputFolder  =  "" , 
309-                         Settings  =  new  TestMsCodeCoverageOptions {  IncludeTestAssembly  =  true } , 
310-                         ExcludedReferencedProjects  =  new  List < string > {  "ExcludedReferenced2" } , 
311-                         IncludedReferencedProjects  =  new  List < string > {  "IncludedReferenced2"  } , 
316+                         TestDllFile  =  "" , 
317+                         Settings  =  new  TestMsCodeCoverageOptions  {  IncludeTestAssembly  =  ! included  } , 
318+                         ExcludedReferencedProjects  =  new  List < string >  {  "ExcludedReferenced2"  } , 
319+                         IncludedReferencedProjects  =  new  List < string >  {  "IncludedReferenced2"  } , 
312320                    } 
313321                } , 
314322            } ; 
315323
316324            var  projectDetails  =  userRunSettingsProjectDetailsLookup . Select ( kvp =>  kvp . Value ) . ToList ( ) ; 
317-             var  allExcludedReferencesProjects  =  projectDetails . SelectMany ( pd =>  pd . ExcludedReferencedProjects ) ; 
318-             var  allIncludedReferencesProjects  =  projectDetails . SelectMany ( pd =>  pd . IncludedReferencedProjects ) ; 
325+             IEnumerable < string >  allReferencedProjects  =  projectDetails . SelectMany ( pd =>  included  ?  pd . IncludedReferencedProjects  :  pd . ExcludedReferencedProjects ) ; 
319326
320327            string  GetExpectedExcludedOrIncludedEscaped ( IEnumerable < string >  excludedOrIncludedReferenced ) 
321328            { 
322329                return  string . Join ( "" ,  excludedOrIncludedReferenced . Select ( referenced =>  ModulePathElement ( MsCodeCoverageRegex . RegexModuleName ( referenced ) ) ) ) ; 
323330            } 
324- 
325-             var  expectedModulePathExcludes  =  GetExpectedExcludedOrIncludedEscaped ( allExcludedReferencesProjects )  +  ModulePathElement ( "ModulePathExclude" ) ; 
326-             var  expectedModulePathIncludes  =  GetExpectedExcludedOrIncludedEscaped ( allIncludedReferencesProjects )  +  ModulePathElement ( "ModulePathInclude" ) ; 
331+             var  expectedExcludes  =  GetExpectedExcludedOrIncludedEscaped ( allReferencedProjects )  +  ModulePathElement ( included  ?  "ModulePathInclude"  :  "ModulePathExclude" ) ; 
327332
328333            var  replacements  =  runSettingsTemplateReplacementsFactory . Create ( testContainers ,  userRunSettingsProjectDetailsLookup ,  null ) ; 
329-             Assert . AreEqual ( expectedModulePathExcludes ,  replacements . ModulePathsExclude ) ; 
330-             Assert . AreEqual ( expectedModulePathIncludes ,  replacements . ModulePathsInclude ) ; 
334+             Assert . AreEqual ( expectedExcludes ,  included  ?  replacements . ModulePathsInclude  :  replacements . ModulePathsExclude ) ; 
331335        } 
332336
333337        [ Test ] 
334-         public  void  Should_Be_Empty_String_Replacement_When_Null ( ) 
338+         public  void  Should_Be_Null_TestAdapter_Replacement_When_Null ( ) 
335339        { 
336340            var  testContainers  =  new  List < ITestContainer > ( ) 
337341            { 
@@ -346,6 +350,7 @@ public void Should_Be_Empty_String_Replacement_When_Null()
346350                    new  TestUserRunSettingsProjectDetails 
347351                    { 
348352                        CoverageOutputFolder  =  "" , 
353+                         TestDllFile  =  "" , 
349354                        Settings  =  new  TestMsCodeCoverageOptions {  IncludeTestAssembly  =  true } , 
350355                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
351356                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -356,14 +361,15 @@ public void Should_Be_Empty_String_Replacement_When_Null()
356361                    new  TestUserRunSettingsProjectDetails 
357362                    { 
358363                        CoverageOutputFolder  =  "" , 
364+                         TestDllFile  =  "" , 
359365                        Settings  =  new  TestMsCodeCoverageOptions {  IncludeTestAssembly  =  true } , 
360366                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
361367                        IncludedReferencedProjects  =  new  List < string > ( ) , 
362368                    } 
363369                } 
364370            } ; 
365371            var  replacements  =  runSettingsTemplateReplacementsFactory . Create ( testContainers ,  userRunSettingsProjectDetailsLookup ,  null ) ; 
366-             ReplacementsAssertions . AssertAllEmpty ( replacements ) ; 
372+             Assert . That ( replacements . TestAdapter ,   Is . Null ) ; 
367373        } 
368374
369375        [ TestCase ( true , true , "true" ) ] 
@@ -386,6 +392,7 @@ public void Should_Be_Disabled_When_All_Projects_Are_Disabled(bool project1Enabl
386392                    new  TestUserRunSettingsProjectDetails 
387393                    { 
388394                        CoverageOutputFolder  =  "" , 
395+                         TestDllFile  =  "" , 
389396                        Settings  =  new  TestMsCodeCoverageOptions {  Enabled  =  project1Enabled ,  IncludeTestAssembly  =  true } , 
390397                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
391398                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -396,6 +403,7 @@ public void Should_Be_Disabled_When_All_Projects_Are_Disabled(bool project1Enabl
396403                    new  TestUserRunSettingsProjectDetails 
397404                    { 
398405                        CoverageOutputFolder  =  "" , 
406+                         TestDllFile  =  "" , 
399407                        Settings  =  new  TestMsCodeCoverageOptions {  Enabled  =  project2Enabled ,   IncludeTestAssembly  =  true } , 
400408                        ExcludedReferencedProjects  =  new  List < string > ( ) , 
401409                        IncludedReferencedProjects  =  new  List < string > ( ) , 
@@ -438,13 +446,14 @@ public void Should_Set_The_TestAdapter()
438446            Assert . AreEqual ( "MsTestAdapterPath" ,  replacements . TestAdapter ) ; 
439447        } 
440448
441-         private  ICoverageProject  CreateCoverageProject ( Action < Mock < ICoverageProject > >  furtherSetup  =  null ) 
449+         private  ICoverageProject  CreateCoverageProject ( Action < Mock < ICoverageProject > >  furtherSetup  =  null ,   bool   includeTestAssembly   =   true ) 
442450        { 
443451            var  mockSettings  =  new  Mock < IAppOptions > ( ) ; 
444-             mockSettings . Setup ( settings =>  settings . IncludeTestAssembly ) . Returns ( true ) ; 
452+             mockSettings . Setup ( settings =>  settings . IncludeTestAssembly ) . Returns ( includeTestAssembly ) ; 
445453            var  mockCoverageProject  =  new  Mock < ICoverageProject > ( ) ; 
446454            mockCoverageProject . Setup ( cp =>  cp . ExcludedReferencedProjects ) . Returns ( new  List < string > ( ) ) ; 
447455            mockCoverageProject . Setup ( cp =>  cp . IncludedReferencedProjects ) . Returns ( new  List < string > ( ) ) ; 
456+             mockCoverageProject . Setup ( cp =>  cp . TestDllFile ) . Returns ( "" ) ; 
448457            mockCoverageProject . Setup ( cp  =>  cp . Settings ) . Returns ( mockSettings . Object ) ; 
449458            furtherSetup ? . Invoke ( mockCoverageProject ) ; 
450459            return  mockCoverageProject . Object ; 
@@ -498,7 +507,6 @@ void AssertReplacement(string replacement, string replacementProperty, bool isIn
498507            } 
499508
500509            AssertReplacement ( replacements . ModulePathsExclude ,  "ModulePath" ,  false ) ; 
501-             AssertReplacement ( replacements . ModulePathsInclude ,  "ModulePath" ,  true ) ; 
502510            AssertReplacement ( replacements . FunctionsExclude ,  "Function" ,  false ) ; 
503511            AssertReplacement ( replacements . FunctionsInclude ,  "Function" ,  true ) ; 
504512            AssertReplacement ( replacements . CompanyNamesExclude ,  "CompanyName" ,  false ) ; 
@@ -541,7 +549,6 @@ void AssertReplacement(string replacement, string replacementProperty, bool isIn
541549            } 
542550
543551            AssertReplacement ( replacements . ModulePathsExclude ,  "ModulePath" ,  false ) ; 
544-             AssertReplacement ( replacements . ModulePathsInclude ,  "ModulePath" ,  true ) ; 
545552
546553            AssertReplacement ( replacements . FunctionsExclude ,  "Function" ,  false ) ; 
547554            AssertReplacement ( replacements . FunctionsInclude ,  "Function" ,  true ) ; 
@@ -556,7 +563,7 @@ void AssertReplacement(string replacement, string replacementProperty, bool isIn
556563        } 
557564
558565        [ Test ] 
559-         public  void  Should_Be_Empty_String_Replacement_When_Null ( ) 
566+         public  void  Should_Be_Null_TestAdapter_Replacement_When_Null ( ) 
560567        { 
561568            var  msCodeCoverageOptions  =  new  TestCoverageProjectOptions 
562569            { 
@@ -565,9 +572,7 @@ public void Should_Be_Empty_String_Replacement_When_Null()
565572
566573            var  coverageProject  =  CreateCoverageProject ( mock =>  mock . Setup ( cp =>  cp . Settings ) . Returns ( msCodeCoverageOptions ) ) ; 
567574            var  replacements  =  runSettingsTemplateReplacementsFactory . Create ( coverageProject ,  null ) ; 
568-             
569- 
570-             ReplacementsAssertions . AssertAllEmpty ( replacements ) ; 
575+             Assert . That ( replacements . TestAdapter ,  Is . Null ) ; 
571576        } 
572577
573578        [ Test ] 
@@ -595,7 +600,7 @@ public void Should_Have_ModulePathsExclude_Replacements_From_ExcludedReferencedP
595600        } 
596601
597602        [ Test ] 
598-         public  void  Should_Have_ModulePathsInclude_Replacements_From_IncludedReferencedProjects_And_Settings ( ) 
603+         public  void  Should_Have_ModulePathsInclude_Replacements_From_IncludedReferencedProjects_Settings_And_Included_Test_Assembly ( ) 
599604        { 
600605            var  msCodeCoverageOptions  =  new  TestCoverageProjectOptions 
601606            { 
@@ -610,10 +615,11 @@ public void Should_Have_ModulePathsInclude_Replacements_From_IncludedReferencedP
610615                { 
611616                    "ModuleName" 
612617                } ) ; 
618+                 mock . Setup ( cp =>  cp . TestDllFile ) . Returns ( @"Path\To\Test.dll" ) ; 
613619            } ) ; 
614620
615621            var  replacements  =  runSettingsTemplateReplacementsFactory . Create ( coverageProject ,  null ) ; 
616-             var  expectedModulePathsInclude  =  $ "{ ModulePathElement ( MsCodeCoverageRegex . RegexModuleName ( "ModuleName" ) ) } { ModulePathElement ( "FromSettings" ) } "; 
622+             var  expectedModulePathsInclude  =  $ "{ ModulePathElement ( MsCodeCoverageRegex . RegexModuleName ( "ModuleName" ) ) } { ModulePathElement ( MsCodeCoverageRegex . RegexEscapePath ( @"Path\To\Test.dll" ) ) } { ModulePathElement ( "FromSettings" ) } "; 
617623            Assert . AreEqual ( expectedModulePathsInclude ,  replacements . ModulePathsInclude ) ; 
618624        } 
619625
0 commit comments