@@ -70,7 +70,7 @@ public void Execute_StateUnderTest_MissingInstrumentationState()
70
70
}
71
71
72
72
[ Fact ]
73
- public void Execute_StateUnderTest_WithInstrumentationState_Fake ( )
73
+ public void Execute_StateUnderTest_WithInstrumentationState_ThresholdType ( )
74
74
{
75
75
// Arrange
76
76
var mockFileSystem = new Mock < IFileSystem > ( ) ;
@@ -89,18 +89,15 @@ public void Execute_StateUnderTest_WithInstrumentationState_Fake()
89
89
BaseTask . ServiceProvider = serviceProvider ;
90
90
_buildEngine . Setup ( x => x . LogErrorEvent ( It . IsAny < BuildErrorEventArgs > ( ) ) ) . Callback < BuildErrorEventArgs > ( e => _errors . Add ( e ) ) ;
91
91
92
- #pragma warning disable CS8604 // Possible null reference argument for parameter..
93
- #pragma warning disable CS8602 // Dereference of a possibly null reference.
94
- var InstrumenterState = new TaskItem ( Path . Combine ( AppDomain . CurrentDomain . SetupInformation . ApplicationBase , "TestAssets\\ InstrumenterState.ItemSpec.data1.xml" ) ) ;
95
- #pragma warning restore CS8602 // Dereference of a possibly null reference.
96
- #pragma warning restore C8S604 // Possible null reference argument for parameter.
92
+ var baseDirectory = AppDomain . CurrentDomain . SetupInformation . ApplicationBase ?? string . Empty ;
93
+ var InstrumenterState = new TaskItem ( Path . Combine ( baseDirectory , "TestAssets\\ InstrumenterState.ItemSpec.data1.xml" ) ) ;
97
94
98
95
var coverageResultTask = new CoverageResultTask
99
96
{
100
97
OutputFormat = "cobertura" ,
101
98
Output = "coverageDir" ,
102
99
Threshold = "50" ,
103
- ThresholdType = "total " ,
100
+ ThresholdType = "line,branch,method " ,
104
101
ThresholdStat = "total" ,
105
102
InstrumenterState = InstrumenterState
106
103
} ;
@@ -110,12 +107,18 @@ public void Execute_StateUnderTest_WithInstrumentationState_Fake()
110
107
bool success = coverageResultTask . Execute ( ) ;
111
108
112
109
// Assert
113
- Assert . True ( success ) ;
114
- Assert . False ( coverageResultTask . Log . HasLoggedErrors ) ;
110
+ Assert . False ( success ) ;
111
+ Assert . True ( coverageResultTask . Log . HasLoggedErrors ) ;
112
+
113
+ // Verify the error message
114
+ string expectedErrorMessage = "The total line coverage is below the specified 50\r \n " +
115
+ "The total branch coverage is below the specified 50\r \n " +
116
+ "The total method coverage is below the specified 50" ;
117
+
118
+ Assert . Contains ( expectedErrorMessage , _errors [ 0 ] . Message ) ;
115
119
116
120
Assert . Contains ( "coverageDir.cobertura.xml" , coverageResultTask . ReportItems [ 0 ] . ItemSpec ) ;
117
121
Assert . Equal ( 16 , coverageResultTask . ReportItems [ 0 ] . MetadataCount ) ;
118
-
119
122
}
120
123
121
124
}
0 commit comments