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.