public void CallIsReplaced() { var dummy = new MethodReplacement(); Action<string> replacement = s => dummy.Call("Intercepted."); InterceptorRegistry.AddInterceptor( new CompoundInterceptor(new AlwaysMatches(), new InsteadOfCall(() => replacement) )); var mocked = new CodeUnderTest(); mocked.CallsConsoleWriteLine(); Assert.AreEqual("Intercepted.", dummy.ReplacementArg1); }
public void MethodWithMatchingOverloadIsIntercepted() { var dummy = new MethodReplacement(); Action<string> replacement = s => dummy.Call("Intercepted."); InterceptorRegistry.AddInterceptor( new CompoundInterceptor(new AllOverloadsMatch(VoidMethod.Of(Console.WriteLine)), new InvokeCallSafe(() => replacement) )); var mocked = new CodeUnderTest(); mocked.CallsConsoleWriteLineFormatStingOverload(); Assert.AreEqual("Intercepted.", dummy.ReplacementArg1); }