public void ShouldLogToNamedLogWhenAttributeProvided() { WithAttribute instance = new WithAttribute(); IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(WithAttribute).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(WithAttribute.LogName, "Entering {0}.{1}", typeof(WithAttribute), "DoSomething"); logger.Received().Trace(WithAttribute.LogName, "Exiting {0}.{1}", typeof(WithAttribute), "DoSomething"); }
public void Deserialize_ClassWithAttribute() { string input = "{ " + "\"__type\" : \"WithAttribute\" " + "}"; WithAttribute result = Deserialize <WithAttribute>(input); Assert.NotNull(result); }
public void Serialize_ClassWithAttribute() { WithAttribute withAttribute = new WithAttribute(); string result = Serialize(withAttribute); Assert.NotNull(result); Assert.Equal( "{ " + "\"__typeAlias\" : \"WithAttribute\" " + "}", result); }
public void ShouldLogToNamedLogWhenAttributeProvided() { WithAttribute instance = new WithAttribute(); IInvocation invocation = Substitute.For<IInvocation>(); invocation.Request.Target.Returns(instance); MethodInfo method = typeof(WithAttribute).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(WithAttribute.LogName, "Entering {0}.{1}", typeof(WithAttribute), "DoSomething"); logger.Received().Trace(WithAttribute.LogName, "Exiting {0}.{1}", typeof(WithAttribute), "DoSomething"); }