1
1
using System . IO ;
2
-
2
+ using System . Linq ;
3
3
using Xunit ;
4
4
5
5
namespace Coverlet . Integration . Tests
@@ -54,8 +54,21 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension()
54
54
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 ) ;
55
55
Assert . Contains ( "Test Run Successful." , standardOutput ) ;
56
56
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" ) ;
59
72
}
60
73
61
74
[ Fact ]
@@ -65,8 +78,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithDoubleExtension()
65
78
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 ) ;
66
79
Assert . Contains ( "Test Run Successful." , standardOutput ) ;
67
80
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" ) ;
70
83
}
71
84
72
85
[ Fact ]
@@ -123,6 +136,35 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
123
136
AssertCoverage ( clonedTemplateProject , "file.*.json" ) ;
124
137
}
125
138
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
+
126
168
[ Fact ]
127
169
public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWithExtension ( )
128
170
{
@@ -135,10 +177,10 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
135
177
136
178
foreach ( string targetFramework in targetFrameworks )
137
179
{
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") ) ) ;
139
181
}
140
182
141
- AssertCoverage ( clonedTemplateProject , "file.*.ext.json " ) ;
183
+ AssertCoverage ( clonedTemplateProject , "file.*.ext" ) ;
142
184
}
143
185
144
186
[ Fact ]
@@ -153,10 +195,10 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
153
195
154
196
foreach ( string targetFramework in targetFrameworks )
155
197
{
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") ) ) ;
157
199
}
158
200
159
- AssertCoverage ( clonedTemplateProject , "file.ext1.*.ext2.json " ) ;
201
+ AssertCoverage ( clonedTemplateProject , "file.ext1.*.ext2" ) ;
160
202
}
161
203
}
162
204
}
0 commit comments