@@ -195,12 +195,41 @@ public void RecordFailureForCurrentPerformableShouldAddTheExceptionStringToTheRe
195195 string performancePhase )
196196 {
197197 sut . BeginPerformable ( performable , actor , performancePhase ) ;
198- sut . RecordFailureForCurrentPerformable ( new Exception ( "An error occurred" ) ) ;
198+ sut . RecordFailureForCurrentPerformable ( new Exception ( "An error occurred" ) , performable , actor ) ;
199199 var report = sut . GetReport ( outcome ) ;
200200 Assert . That ( report . Reportables ,
201201 Has . One . Matches < PerformableReport > ( x => x . Exception . Contains ( "An error occurred" ) && x . ExceptionIsFromConsumedPerformable == false ) ) ;
202202 }
203203
204+ [ Test , AutoMoqData ]
205+ public void RecordFailureForCurrentPerformableShouldSetTheReportString ( PerformanceReportBuilder sut ,
206+ [ NamedActor ( "Joe" ) ] Actor actor ,
207+ bool ? outcome ,
208+ string performable ,
209+ string performancePhase )
210+ {
211+ sut . BeginPerformable ( performable , actor , performancePhase ) ;
212+ sut . RecordFailureForCurrentPerformable ( new Exception ( "An error occurred" ) , performable , actor ) ;
213+ var report = sut . GetReport ( outcome ) ;
214+ Assert . That ( report . Reportables ,
215+ Has . One . Matches < PerformableReport > ( x => x . Report != null ) ) ;
216+ }
217+
218+ [ Test , AutoMoqData ]
219+ public void RecordFailureForCurrentPerformableShouldUseAFallbackReportIfGettingTheReportThrows ( PerformanceReportBuilder sut ,
220+ [ NamedActor ( "Joe" ) ] Actor actor ,
221+ bool ? outcome ,
222+ ICanReport performable ,
223+ string performancePhase )
224+ {
225+ Mock . Get ( performable ) . Setup ( x => x . GetReportFragment ( actor , It . IsAny < IFormatsReportFragment > ( ) ) ) . Throws < InvalidOperationException > ( ) ;
226+ sut . BeginPerformable ( performable , actor , performancePhase ) ;
227+ sut . RecordFailureForCurrentPerformable ( new Exception ( "An error occurred" ) , performable , actor ) ;
228+ var report = sut . GetReport ( outcome ) ;
229+ Assert . That ( report . Reportables ,
230+ Has . One . Matches < PerformableReport > ( x => x . Report == "An unexpected error occurred getting the report text for this performable" ) ) ;
231+ }
232+
204233 [ Test , AutoMoqData ]
205234 public void RecordFailureForCurrentPerformableShouldSetExceptionIsFromConsumedPerformableToTrueIfTheExceptionIsPerformableException ( PerformanceReportBuilder sut ,
206235 [ NamedActor ( "Joe" ) ] Actor actor ,
@@ -209,7 +238,7 @@ public void RecordFailureForCurrentPerformableShouldSetExceptionIsFromConsumedPe
209238 string performancePhase )
210239 {
211240 sut . BeginPerformable ( performable , actor , performancePhase ) ;
212- sut . RecordFailureForCurrentPerformable ( new PerformableException ( "An error occurred" ) ) ;
241+ sut . RecordFailureForCurrentPerformable ( new PerformableException ( "An error occurred" ) , performable , actor ) ;
213242 var report = sut . GetReport ( outcome ) ;
214243 Assert . That ( report . Reportables ,
215244 Has . One . Matches < PerformableReport > ( x => x . Exception . Contains ( "An error occurred" ) && x . ExceptionIsFromConsumedPerformable == true ) ) ;
0 commit comments