mercredi 7 octobre 2015

Test class method that calls private method in C# using moq and Xunit

I have the following legacy class that I want to add some unit tests to using Xunit and Moq

The psuedo code for the class I want to test is below:-

public class Foo : IFoo
{

       public StatusResposne GetStatus(string jobId)
       {
                   .
                   .
             var response = GetRequest(doc, targeturl);
                   .
                   .
       }

        private XDocument GetRequest(XDocument doc, string url)
        {
        }
}

Now i want to test GetStatus but im order to do that i need to mock the GetRequest method.

Can anyone suggest the easiest way to do this?

Cheers

Aucun commentaire:

Enregistrer un commentaire