Esempio n. 1
0
 public void ObtainObjectsOfExpectedType()
 {
     Assert.IsInstanceOfType(
         LoggingProxyFactory.Create <ITestObject>(
             (_) =>
     {
         _.CreateFunction(() =>
         {
             return(new TestObject());
         });
     })
         , typeof(ITestObject));
 }
Esempio n. 2
0
        public void LogEveryOperationEvenWithArgs()
        {
            ILog logger = A.Fake <ILog>();

            var sut = LoggingProxyFactory.Create <ITestObject>(
                (_) =>
            {
                _.UsingLogger(logger);
                _.CreateFunction(() =>
                {
                    return(new TestObject());
                });
            });

            sut.TestMethod(1);

            A.CallTo(() => logger.Info("Executing 'TestMethod' with Args (1)")).MustHaveHappened(Repeated.Exactly.Once);
        }
Esempio n. 3
0
        public void LogException()
        {
            ILog logger = A.Fake <ILog>();

            var sut = LoggingProxyFactory.Create <ITestObject>(
                (_) =>
            {
                _.UsingLogger(logger);
                _.CreateFunction(() =>
                {
                    return(new TestObject());
                });
            });

            sut.ExceptionMethod();
            A.CallTo(() => logger.Error("Exception Object reference not set to an instance of an object. occurred executing 'ExceptionMethod'"
                                        , new NullReferenceException()))
            .MustHaveHappened(Repeated.Exactly.Once);
        }