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
I have some code, simplified as follows. It is an abstract class and a child class.

Here is the abstract class. I know there aren't any abstract methods, it's ok.. for this example, it works. Notice that I have both a normal method and a static method named the same (Reg). Note also they have different arguments, meaning different signatures.

    public abstract class Parent
    {
        private string _s;

        public Parent()
            : this("empty")
        {
        }

        public Parent(string s) {
            _s = s;
        }

        public void Reg()
        {
            Parent.Reg(_s);
        }

        public static void Reg(string word) 
        {
            Console.WriteLine(word);
        }
    }


And here is my concrete class, inheriting from Parent. Simple enough.

    public class Child : Parent
    {
        public Child(string s)
            : base(s + ": from child")
        {
        }
    }


Here is how I test it.

        public void RegTest()
        {
            string s = "eric";
            Child target = new Child(s);
            MockManager.Init();
            
            using (RecordExpectations r = RecorderManager.StartRecording())
            {
                Parent.Reg(s);
            }

            target.Reg();

            MockManager.Verify();
        }


Parent.Reg (the static method) gets called through! The test fails because "Method TMtest.Parent.Reg() has 1 more expected calls"

TypeMock trace reports under "MockAllInstances" Reg(0/1) while under Static Reg(1) (and it notes this was an unexpected call).

So how do I get TypeMock to mock the static call?

Thanks!

-Eric
________
vapir oxygen
asked by erichorne (3.4k points)

1 Answer

0 votes
Hi Eric,
This is actually a bug. It happens with overloaded method.

We will fix this and send you the fix offline.
answered by scott (32k points)
...