public void TestIfItCanRedirectAMethodCall() { // Arrange int expectedNumber = 5; TestClass source = new TestClass(); IExtraTestInterface <int> target; // Act target = source.Proxify() .Redirect(subject => subject.IntOverloaded(With.Arg <string>())) .Into <IExtraTestInterface <int> >() .WithMethod(proxy => proxy.ExtraMethod(With.Arg <int>()), (int number) => number.ToString()) .WithReturn(result => result.ToString()) .Proxy; string actual = target.ExtraMethod(expectedNumber); // Assert Assert.That(target, Is.Not.Null); Assert.That(actual, Is.EqualTo(TestClass.IntOverloadedStringReturn.ToString())); // Reset TestClass.IntOverloadedStringReturn = int.MinValue; }
public void TestIfItCanRedirectAVoidMethodCall() { // Arrange int expectedNumber = 5; TestClass source = new TestClass(); IExtraTestInterface <int> target; // Act target = source.Proxify() .Redirect(subject => subject.VoidOverloaded(With.Arg <String>())) .Into <IExtraTestInterface <int> >() .WithMethod(proxy => proxy.ExtraVoidMethod(With.Arg <int>()), (int number) => number.ToString()) .Proxy; target.ExtraVoidMethod(expectedNumber); // Assert Assert.That(target, Is.Not.Null); Assert.That(source.VoidOverloadedStringCalled, Is.True); }