I am trying to write a unit test for an existing method. One of the things this method does is call a web service with IRestClient. This line of code is:
var jobs = Client.Get<Dictionary<string, string>>(request).Data;
where Client is an IRestClient and Data is a Dictionary of string -> string.
In my UT method, I try to create the Substitute object for the IRestClient by doing this:
var restResponse = Substitute.For<IRestResponse<Dictionary<string, string>>>(); restClient.Get<Dictionary<string, string>>(Arg.Any<IRestRequest>()).Returns(restResponse);
However, on the 2nd line I get a null reference exception. Using the watch window, I have confirmed that restClient an restResponse are NOT null.
I am guessing the null object is something inside NSubstitute, and that I'm trying to do something NSubstitute does not support.
Can anyone explain what's going on here? For now my workaround is to just create my own implementation of IRestClient.