Hi friends,
I am trying to mock static functions in my project. I am unable to do this using Rhynomocks hence trying to mock static functions using Typemock.
I am trying below Example:
https://www.typemock.com/basic-typemock-unit-testing
however it doesn't seem to work for me. Below is my code:
public class Class1Test
{
[Isolated(Design = DesignMode.Pragmatic)]
[Test]
public void function()
{
Isolate.Fake.StaticMethods<LoggerFactory>(Members.MustSpecifyReturnValues);
Isolate.WhenCalled(() => LoggerFactory.Add(6, 4)).WillReturn(11);
int value = LoggerFactory.Add(5, 6);
}
}
-----------------------------------------------LoggerFactory.cs
public class LoggerFactory
{
public static int Add(int intx, int inty)
{
return intx + inty;
}
}
Error what I get is:
*** Faking non-virtual methods is not possible in InterfaceOnly design mode. Use [Isolated(DesignMode.Pragmatic)] to fake this. Learn more here
https://www.typemock.com/isolator-design-mode
Thanks in advance.