public void IsLoginOK_WhenCalled_WritesToLog() { ILogger fake = A.Fake <ILogger>(); LoginManagerWithMock lm = new LoginManagerWithMock(fake); lm.IsLoginOK("", ""); A.CallTo(() => fake.Write(A <string> .Ignored)).MustHaveHappened(); }
public void IsLoginOK_WhenLoggerThrows_CallsWebService() { ILogger fakeLog = A.Fake <ILogger>(); IWebService fakeWs = A.Fake <IWebService>(); A.CallTo(() => fakeLog.Write(A <string> .Ignored)) .Throws(new LoggerException()); LoginManagerWithMockAndStub lm = new LoginManagerWithMockAndStub(fakeLog, fakeWs); lm.IsLoginOK("", ""); A.CallTo(() => fakeWs.Write( A <string> .That.Contains("got exception"))) .MustHaveHappened(); }