public void ShouldLogToNullWhenAttributeMissing() { NoAttribute instance = new NoAttribute(); IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(NoAttribute).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); ILogger logger = Substitute.For <ILogger>(); IKernel kernel = new StandardKernel(); kernel.Bind <ILogger>().ToConstant(logger); invocation.Request.Kernel.Returns(kernel); LogInterceptor interceptor = new LogInterceptor(); interceptor.Intercept(invocation); logger.Received().Trace("null", "Entering {0}.{1}", typeof(NoAttribute), "DoSomething"); logger.Received().Trace("null", "Exiting {0}.{1}", typeof(NoAttribute), "DoSomething"); }
public void ShouldNotCreateTransactionIfMissingAttribute() { NoAttribute instance = new NoAttribute(); IInvocation invocation = Substitute.For<IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(NoAttribute).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); TransactionInterceptor interceptor = new TransactionInterceptor(); interceptor.Intercept(invocation); Assert.IsFalse(instance.HadTransaction, "There should be no active transaction."); }
public void ShouldNotCreateTransactionIfMissingAttribute() { NoAttribute instance = new NoAttribute(); IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(NoAttribute).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); TransactionInterceptor interceptor = new TransactionInterceptor(); interceptor.Intercept(invocation); Assert.IsFalse(instance.HadTransaction, "There should be no active transaction."); }
public void ShouldLogToNullWhenAttributeMissing() { NoAttribute instance = new NoAttribute(); IInvocation invocation = Substitute.For<IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(NoAttribute).GetMethod("DoSomething"); invocation.Request.Method.Returns(method); invocation.When(i => i.Proceed()).Do(i => instance.DoSomething()); ILogger logger = Substitute.For<ILogger>(); IKernel kernel = new StandardKernel(); kernel.Bind<ILogger>().ToConstant(logger); invocation.Request.Kernel.Returns(kernel); LogInterceptor interceptor = new LogInterceptor(); interceptor.Intercept(invocation); logger.Received().Trace("null", "Entering {0}.{1}", typeof(NoAttribute), "DoSomething"); logger.Received().Trace("null", "Exiting {0}.{1}", typeof(NoAttribute), "DoSomething"); }