chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
in the example bellow i am expecting MyClass.MethodName(); to be called and MyClass.MethodName(true); to be mocked that is not the case
[TestFixture]
    public class Tests
    {
        [Test]
        public void Test()
        {
            Mock mockAllMyClass = MockManager.MockAll(typeof (MyClass));
            mockAllMyClass.ExpectCall("MethodName").Args(true);

            MyClass.MethodName();
        }
    }
    public class MyClass
    {
        public static void MethodName()
        {
            MethodName(true);
        }
        public static void MethodName(bool match)
        {
            
        }
    }
asked by tolisss (28.8k points)

1 Answer

0 votes
H,

Currently handling overloads method is a known limitation of the Isolator framework. In your case when you set up an expectation on MethodName the first call (the one without the parameters) is caught and mocked.

A simple work around for this would be:
Mock mockAllMyClass = MockManager.MockAll(typeof(MyClass));
mockAllMyClass.ExpectUnmockedCall("MethodName");
mockAllMyClass.ExpectCall("MethodName").Args(true);

MyClass.MethodName(); 


We are aware this is not nice but still it should make the job done (at least until we implement the full support for overload methods)
answered by lior (13.2k points)
...