public void IfNotInterruptShouldCallUnderlyingObjectMethod() { // Given var testClass = new TestClass(); var interceptor = new LastInvocationInterceptor(); var factory = new CastleCoreProxyFactory <ITestClass>(); var proxy = factory.CreateProxy(testClass, interceptor); // When var result = proxy.GetNextInt(10); // Then Assert.Equal(11, result); }
public void ShouldIntercept() { // Given var testClass = new TestClass(); var interceptor = new LastInvocationInterceptor(); var factory = new CastleCoreProxyFactory <ITestClass>(); var proxy = factory.CreateProxy(testClass, interceptor); // When proxy.GetNextInt(10); // Then var invocation = interceptor.LastInvocationParameter; Assert.NotNull(invocation); Assert.Equal(nameof(testClass.GetNextInt), invocation.Method.Name); }
public void ShouldPassArguments() { // Given var testClass = new TestClass(); var interceptor = new LastInvocationInterceptor(); var factory = new CastleCoreProxyFactory <ITestClass>(); var proxy = factory.CreateProxy(testClass, interceptor); // When proxy.GetNextInt(10); // Then var invocation = interceptor.LastInvocationParameter; Assert.NotNull(invocation); var argument = Assert.Single(invocation.Arguments); Assert.Equal(10, argument); }