11// Copyright (c) Toni Solarin-Sodara
22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
4+ using System ;
45using System . IO ;
56using System . Linq ;
67using Xunit ;
@@ -32,8 +33,8 @@ public void TestMsbuild()
3233 {
3334 using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
3435 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\" { clonedTemplateProject . ProjectRootPath } \" \\ ", out string standardOutput , out string standardError ) , standardOutput ) ;
35- Assert . Contains ( "Passed!" , standardOutput ) ;
36- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
36+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
37+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
3738 Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "coverage.json" ) ) ) ;
3839 AssertCoverage ( clonedTemplateProject ) ;
3940 }
@@ -44,7 +45,7 @@ public void TestMsbuild_NoCoverletOutput()
4445 using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
4546 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true", out string standardOutput , out string standardError ) , standardOutput ) ;
4647 Assert . Contains ( "Passed!" , standardOutput ) ;
47- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
48+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
4849 Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "coverage.json" ) ) ) ;
4950 AssertCoverage ( clonedTemplateProject ) ;
5051 }
@@ -54,8 +55,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithoutExtension()
5455 {
5556 using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
5657 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\" { clonedTemplateProject . ProjectRootPath } \" \\ file", out string standardOutput , out string standardError ) , standardOutput ) ;
57- Assert . Contains ( "Passed!" , standardOutput ) ;
58- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
58+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
59+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
5960 Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.json" ) ) ) ;
6061 AssertCoverage ( clonedTemplateProject , "file.json" ) ;
6162 }
@@ -65,8 +66,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension()
6566 {
6667 using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
6768 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { 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 ( "Passed!" , standardOutput ) ;
69- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
69+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
70+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
7071 Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext" ) ) ) ;
7172 AssertCoverage ( clonedTemplateProject , "file.ext" ) ;
7273 }
@@ -78,8 +79,16 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension_SpecifyFramework
7879 Assert . False ( clonedTemplateProject . IsMultipleTargetFramework ( ) ) ;
7980 string framework = clonedTemplateProject . GetTargetFrameworks ( ) . Single ( ) ;
8081 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } -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 ) ;
81- Assert . Contains ( "Passed!" , standardOutput ) ;
82- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
82+ if ( ! string . IsNullOrEmpty ( standardError ) )
83+ {
84+ _output . WriteLine ( standardError ) ;
85+ }
86+ else
87+ {
88+ _output . WriteLine ( standardOutput ) ;
89+ }
90+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
91+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
8392 Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext" ) ) ) ;
8493 AssertCoverage ( clonedTemplateProject , "file.ext" ) ;
8594 }
@@ -89,8 +98,15 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithDoubleExtension()
8998 {
9099 using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject ( ) ;
91100 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { 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 ) ;
92- Assert . Contains ( "Passed!" , standardOutput ) ;
93- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
101+ if ( ! string . IsNullOrEmpty ( standardError ) )
102+ {
103+ _output . WriteLine ( standardError ) ;
104+ } else
105+ {
106+ _output . WriteLine ( standardOutput ) ;
107+ }
108+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
109+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
94110 Assert . True ( File . Exists ( Path . Combine ( clonedTemplateProject . ProjectRootPath , "file.ext1.ext2" ) ) ) ;
95111 AssertCoverage ( clonedTemplateProject , "file.ext1.ext2" ) ;
96112 }
@@ -102,8 +118,8 @@ public void Test_MultipleTargetFrameworkReport_NoCoverletOutput()
102118 string [ ] targetFrameworks = new string [ ] { "net6.0" , "net7.0" } ;
103119 UpdateProjectTargetFramework ( clonedTemplateProject , targetFrameworks ) ;
104120 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true", out string standardOutput , out string standardError , clonedTemplateProject . ProjectRootPath ! ) , standardOutput ) ;
105- Assert . Contains ( "Passed!" , standardOutput ) ;
106- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
121+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
122+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
107123
108124 foreach ( string targetFramework in targetFrameworks )
109125 {
@@ -125,8 +141,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder()
125141 _output . WriteLine ( standardError ) ;
126142 }
127143 Assert . True ( result ) ;
128- Assert . Contains ( "Passed!" , standardOutput ) ;
129- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
144+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
145+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
130146
131147 foreach ( string targetFramework in targetFrameworks )
132148 {
@@ -144,8 +160,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
144160 string [ ] targetFrameworks = new string [ ] { "net6.0" , "net7.0" } ;
145161 UpdateProjectTargetFramework ( clonedTemplateProject , targetFrameworks ) ;
146162 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { clonedTemplateProject . ProjectRootPath } \" /p:CollectCoverage=true /p:Include=\" [{ ClonedTemplateProject . AssemblyName } ]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\" { clonedTemplateProject . ProjectRootPath } \" \\ file", out string standardOutput , out string standardError , clonedTemplateProject . ProjectRootPath ! ) , standardOutput ) ;
147- Assert . Contains ( "Passed!" , standardOutput ) ;
148- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
163+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
164+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
149165
150166 foreach ( string targetFramework in targetFrameworks )
151167 {
@@ -166,8 +182,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
166182 Assert . Equal ( 2 , frameworks . Length ) ;
167183 string framework = frameworks . FirstOrDefault ( ) ! ;
168184 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } -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 ) ;
169- Assert . Contains ( "Passed!" , standardOutput ) ;
170- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
185+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
186+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
171187
172188 foreach ( string targetFramework in targetFrameworks )
173189 {
@@ -191,8 +207,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
191207 string [ ] targetFrameworks = new string [ ] { "net6.0" , "net7.0" } ;
192208 UpdateProjectTargetFramework ( clonedTemplateProject , targetFrameworks ) ;
193209 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { 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 ) ;
194- Assert . Contains ( "Passed!" , standardOutput ) ;
195- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
210+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
211+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
196212
197213 foreach ( string targetFramework in targetFrameworks )
198214 {
@@ -209,8 +225,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit
209225 string [ ] targetFrameworks = new string [ ] { "net6.0" , "net7.0" } ;
210226 UpdateProjectTargetFramework ( clonedTemplateProject , targetFrameworks ) ;
211227 Assert . True ( DotnetCli ( $ "test -c { _buildConfiguration } \" { 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 , clonedTemplateProject . ProjectRootPath ! ) , standardOutput ) ;
212- Assert . Contains ( "Passed!" , standardOutput ) ;
213- Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput ) ;
228+ Assert . Contains ( "Passed!" , standardOutput , StringComparison . Ordinal ) ;
229+ Assert . Contains ( "| coverletsamplelib.integration.template | 100% | 100% | 100% |" , standardOutput , StringComparison . Ordinal ) ;
214230
215231 foreach ( string targetFramework in targetFrameworks )
216232 {
0 commit comments