コード例 #1
0
        public void IsLoginOK_WhenCalled_WritesToLog()
        {
            Isolate.Fake.StaticMethods(typeof(StaticLogger));
            var lm = new LoginManagerWithStatics();

            lm.IsLoginOK("a", "b");

            Isolate.Verify
            .WasCalledWithAnyArguments(() => StaticLogger.Write(""));
        }
コード例 #2
0
        public void IsLoginOK_StaticLoggerThrowsException_CallsStaticWebService()
        {
            Isolate.Fake.StaticMethods <StaticLogger>();
            Isolate.Fake.StaticMethods <StaticWebService>();
            Isolate
            .WhenCalled(() => StaticLogger.Write("anything"))
            .WillThrow(new LoggerException("fake exception"));


            var lm = new LoginManagerWithStatics();

            lm.IsLoginOK("a", "b");

            Isolate.Verify.WasCalledWithAnyArguments(() =>
                                                     StaticWebService.Write(""));
        }
コード例 #3
0
        public void IsLoginOK_StaticLoggerThrowsException_CallsStaticWebServiceWithCorrectText()
        {
            string textWrittenToWebService = null;

            Isolate.Fake.StaticMethods <StaticLogger>();
            Isolate.Fake.StaticMethods <StaticWebService>();
            Isolate
            .WhenCalled(() => StaticLogger.Write(""))
            .WillThrow(new LoggerException("fake exception"));

            Isolate
            .WhenCalled(() => StaticWebService.Write(""))
            .DoInstead(context =>
                       textWrittenToWebService = (string)context.Parameters[0]);

            var lm = new LoginManagerWithStatics();

            lm.IsLoginOK("a", "b");


            StringAssert.Contains("fake exception", textWrittenToWebService);
        }