简体   繁体   中英

TypeMock Faking static method in static class

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?

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM