@@ -67,7 +67,7 @@ public void Test_EmployeeInOfficeGetsNotified_UsingStrictMock()
6767 // Create mocks:
6868 //
6969 var loggerMock = Isolate . Fake . Instance < ILogger > ( ) ;
70-
70+
7171 var bobMock = Isolate . Fake . Instance < IEmployee > ( ) ;
7272 Isolate . WhenCalled ( ( ) => bobMock . IsWorkingOnDate ( DateTime . MinValue ) ) . WillReturn ( true ) ;
7373 Isolate . WhenCalled ( ( ) => bobMock . GetNotificationPreference ( ) ) . WillReturn ( LunchNotifier . NotificationType . Email ) ;
@@ -76,7 +76,7 @@ public void Test_EmployeeInOfficeGetsNotified_UsingStrictMock()
7676 Isolate . WhenCalled ( ( ) => employeeServiceMock . GetEmployeesInNewYorkOffice ( ) ) . WillReturn ( new [ ] { bobMock } ) ;
7777
7878 var notificationServiceMock = Isolate . Fake . Instance < INotificationService > ( Members . MustBeSpecified ) ;
79- Isolate . WhenCalled ( ( ) => notificationServiceMock . SendEmail ( null , null ) ) ;
79+ Isolate . WhenCalled ( ( ) => notificationServiceMock . SendEmail ( null , null ) ) . IgnoreCall ( ) ;
8080
8181 //
8282 // Create instance of class I'm testing:
@@ -95,7 +95,9 @@ public void Test_EmployeeInOfficeGetsNotified_UsingStrictMock()
9595 Isolate . Verify . WasCalledWithArguments ( ( ) => notificationServiceMock . SendEmail ( null , null ) )
9696 . Matching ( args => ( ( IEmployee ) args [ 0 ] ) . Equals ( bobMock ) ) ;
9797
98- Assert . Fail ( "Not working as a strict mock" ) ;
98+ // Since the notification mock calls are wrapped in a try/catch where the exeception is just
99+ // logged, we need to ensure the error logger was never called due to our strict mock failing.
100+ Isolate . Verify . WasNotCalled ( ( ) => loggerMock . Error ( null ) ) ;
99101
100102 }
101103
@@ -122,7 +124,7 @@ public void Test_ExceptionDoesNotStopNotifications()
122124
123125 var notificationServiceMock = Isolate . Fake . Instance < INotificationService > ( ) ;
124126 Isolate . WhenCalled ( ( ) => notificationServiceMock . SendEmail ( null , null ) ) . WillThrow ( new Exception ( ) ) ;
125-
127+
126128 //
127129 // Create instance of class I'm testing:
128130 //
@@ -172,7 +174,7 @@ public void Test_CorrectTemplateIsUsed_LateLunch(string currentTime, string expe
172174 var notificationServiceMock = Isolate . Fake . Instance < INotificationService > ( ) ;
173175
174176 Isolate . WhenCalled ( ( ) => System . DateTime . Now ) . WillReturn ( DateTime . Parse ( currentTime ) ) ;
175-
177+
176178 //
177179 // Create instance of class I'm testing:
178180 //
0 commit comments