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_WhenCalled_WritesToLog_AAA()
        {
            ILogger fake = Substitute.For <ILogger>();

            LoginManagerWithMock lm = new LoginManagerWithMock(fake);

            lm.IsLoginOK("", "");

            fake.Received().Write(Arg.Is <string>(s => s.Contains("login ok: user: u")));
        }
        public void IsLoginOK_LoggerError_CallsWs()
        {
            IWebService svc  = Substitute.For <IWebService>();
            ILogger     fake = Substitute.For <ILogger>();

            fake.When(logger => logger.Write(Arg.Any <string>()))
            .Do(info =>
            {
                throw new LoggerException("fake exception");
            });

            var lm = new LoginManagerWithMockAndStub(fake, svc);

            lm.IsLoginOK("", "");

            svc.Received().Write(Arg.Any <string>());
        }
        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();
        }