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
0 votes
The code:

----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;


namespace ClassLibrary3
{
    public class ClassA<D>
    {
 
        static ClassA()
        {
 
        }

        public void MethodOnClassA(int val)
        {
            throw new NotImplementedException();

        }
        public static void MethodOnClassA(string foo)
        {
            throw new NotImplementedException();
        }

    }

    public class ClassB<D>
    {
        public ClassB()
        {

        }
        public void MethodOnClassB()
        {
          ClassA<D>.MethodOnClassA("bar");

        }
    }
}


----------------------------------------------------------------

The Unit Test :

..........
    public class MyClass{};


..........
       /// <summary>
        ///A test for MethodB ()
        ///</summary>
        [TestMethod()]
        public void MethodOnClassBTest()
        {
            ClassB<MyClass> target = new ClassB<MyClass>();
            Mock mockObj = MockManager.MockAll(typeof(ClassA<MyClass>));

            mockObj.ExpectAlways("MethodOnClassA");

            target.MethodOnClassB();
        }

----------------------------------------------------------------

Test will fail with a "NotImplementedException". Typemock seems to ONLY mock the FIRST occurrence of the method to be mocked. Typemock tracer will log the call as an "unexpected call".

However, if you reverse the order of the two "MethodOfClassA" definitions (i.e. define the Static method first and then the instance method), the test will pass.
asked by beejaydee (600 points)

1 Answer

0 votes
Hi,
It seems like a bug :twisted:
We will investiage this issue and send you a patch.
answered by scott (32k points)
...