TypeMock Faking static method in static class

988 views Asked by At

Using TypeMock Isolator...

I am trying to Mock a static method call that is inside a static class but it keeps calling the original code.

I ran across this thread and I am doing exactly what they suggest but still not luck.

I have tried doing it 2 different ways:

1:

Isolate.Fake.StaticMethods(typeof(QueueDAO), Members.ReturnRecursiveFakes);

2:

Isolate.WhenCalled(() => QueueDAO.UpdateQueueStatus(queueCmtId, CmtQueueStatus.Error)).IgnoreCall();

Neither solution works. Does it have something to do with the enumeration that is passed in?

2

There are 2 answers

0
Eli On

Both should work. By default arguments are ignored so the second should work too. Do you have [Isolated] on the test class or method?

You might have another isolate method that overrides this one. Please see if a simple test that isolates updatequeuestatus and then calls it directly works? If not turn on logging and send them to support (at) typemock.com for analysis.

0
Fish On

The object passed in as the typeof should be the class which contains the static methods, not the object itself.

Isolate.Fake.StaticMethods(typeof(QueueDAO));

Does the QueueDAO object contain static methods, or is there an extensions class?