tonerdo / pose

Replace any .NET method (including static and non-virtual) with a delegate
MIT License
1.07k stars 75 forks source link

Pose.Exceptions.InvalidShimSignatureException: 'Parameters count do not match“ #50

Closed cc5zhenhua closed 5 years ago

cc5zhenhua commented 5 years ago

` public class ShimTest { public void runTest() { TestModel testObj = new TestModel(); Shim boShim = Shim.Replace(() => testObj.testMethod(Is.A"<"string">"())).With((TestModel obj) => "test"); // line here throw exceptions as titled, anything wrong? PoseContext.Isolate(() => { testObj.testMethod(""); }, boShim); }
}

public class TestModel
{
    public string testMethod(string pa)
    {
        return "hello,world";
    }
}`
cc5zhenhua commented 5 years ago

(Is.A"<"string">"() can't show directly so add extra quota, not typo. Thanks.

cc5zhenhua commented 5 years ago

Find the solution as following: Shim boShim = Shim.Replace(() => testObj.testMethod(Is.A"<"string">"())).With((TestModel obj,string t) => "test");