Mocking Static classes using Typemock

1.4k Views Asked by At

I am having a class as follows. I would like to know how can we mock this class using Typemock

public static class MyClass
{
   public static string MyFunction()
   {

   }
}
1

There are 1 best solutions below

5
Travis Illig On

There's no special syntax required for static method mocking. You should be able to use the AAA syntax as usual.

Isolate.Fake.WhenCalled(() => MyClass.MyFunction()).WillReturn("mock");

There is some great documentation about this on the Typemock site.