chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
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.
asked by ranjith227 (600 points)

1 Answer

0 votes
Hi ranjith,

I've sent you license to your email.
Please let me know if it solved the issue.
answered by alex (17k points)
...