11using System . IO ;
2-
2+ using System . Linq ;
33using Xunit ;
44
55namespace Coverlet . Integration . Tests
@@ -54,8 +54,21 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension()
5454 Assert . True ( DotnetCli ( $ "test \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\" { clonedTemplateProject . ProjectRootPath } \" \\ file.ext", out string standardOutput , out string standardError ) , standardOutput ) ;
5555 Assert . Contains ( "Test Run Successful." , standardOutput ) ;
5656 Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
57- Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext.json" ) ) ) ;
58- AssertCoverage ( clonedTemplateProject , "file.ext.json" ) ;
57+ Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext" ) ) ) ;
58+ AssertCoverage ( clonedTemplateProject , "file.ext" ) ;
59+ }
60+
61+ [ Fact ]
62+ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension_SpecifyFramework ( )
63+ {
64+ using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
65+ Assert . False ( clonedTemplateProject . IsMultipleTargetFramework ( ) ) ;
66+ string framework = clonedTemplateProject . GetTargetFrameworks ( ) . Single ( ) ;
67+ Assert . True ( DotnetCli ( $ "test -f { framework } \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\" { clonedTemplateProject . ProjectRootPath } \" \\ file.ext", out string standardOutput , out string standardError ) , standardOutput ) ;
68+ Assert . Contains ( "Test Run Successful." , standardOutput ) ;
69+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
70+ Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext" ) ) ) ;
71+ AssertCoverage ( clonedTemplateProject , "file.ext" ) ;
5972 }
6073
6174 [ Fact ]
@@ -65,8 +78,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithDoubleExtension()
6578 Assert . True ( DotnetCli ( $ "test \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\" { clonedTemplateProject . ProjectRootPath } \" \\ file.ext1.ext2", out string standardOutput , out string standardError ) , standardOutput ) ;
6679 Assert . Contains ( "Test Run Successful." , standardOutput ) ;
6780 Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
68- Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext1.ext2.json " ) ) ) ;
69- AssertCoverage ( clonedTemplateProject , "file.ext1.ext2.json " ) ;
81+ Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext1.ext2" ) ) ) ;
82+ AssertCoverage ( clonedTemplateProject , "file.ext1.ext2" ) ;
7083 }
7184
7285 [ Fact ]
@@ -123,6 +136,35 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
123136 AssertCoverage ( clonedTemplateProject , "file.*.json" ) ;
124137 }
125138
139+ [ Fact ]
140+ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWithExtension_SpecifyFramework ( )
141+ {
142+ using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
143+ string [ ] targetFrameworks = new string [ ] { "netcoreapp2.2" , "netcoreapp2.1" } ;
144+ UpdateProjectTargetFramework ( clonedTemplateProject , targetFrameworks ) ;
145+ Assert . True ( clonedTemplateProject . IsMultipleTargetFramework ( ) ) ;
146+ string [ ] frameworks = clonedTemplateProject . GetTargetFrameworks ( ) ;
147+ Assert . Equal ( 2 , frameworks . Length ) ;
148+ string framework = frameworks . FirstOrDefault ( ) ;
149+ Assert . True ( DotnetCli ( $ "test -f { framework } \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\" { clonedTemplateProject . ProjectRootPath } \" \\ file.ext", out string standardOutput , out string standardError , clonedTemplateProject . ProjectRootPath ! ) , standardOutput ) ;
150+ Assert . Contains ( "Test Run Successful." , standardOutput ) ;
151+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
152+
153+ foreach ( string targetFramework in targetFrameworks )
154+ {
155+ if ( framework == targetFramework )
156+ {
157+ Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , $ "file.{ targetFramework } .ext") ) ) ;
158+ }
159+ else
160+ {
161+ Assert . False ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , $ "file.{ targetFramework } .ext") ) ) ;
162+ }
163+ }
164+
165+ AssertCoverage ( clonedTemplateProject , "file.*.ext" ) ;
166+ }
167+
126168 [ Fact ]
127169 public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWithExtension ( )
128170 {
@@ -135,10 +177,10 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
135177
136178 foreach ( string targetFramework in targetFrameworks )
137179 {
138- Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , $ "file.{ targetFramework } .ext.json ") ) ) ;
180+ Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , $ "file.{ targetFramework } .ext") ) ) ;
139181 }
140182
141- AssertCoverage ( clonedTemplateProject , "file.*.ext.json " ) ;
183+ AssertCoverage ( clonedTemplateProject , "file.*.ext" ) ;
142184 }
143185
144186 [ Fact ]
@@ -153,10 +195,10 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
153195
154196 foreach ( string targetFramework in targetFrameworks )
155197 {
156- Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , $ "file.ext1.{ targetFramework } .ext2.json ") ) ) ;
198+ Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , $ "file.ext1.{ targetFramework } .ext2") ) ) ;
157199 }
158200
159- AssertCoverage ( clonedTemplateProject , "file.ext1.*.ext2.json " ) ;
201+ AssertCoverage ( clonedTemplateProject , "file.ext1.*.ext2" ) ;
160202 }
161203 }
162204}
0 commit comments