For each return type that you expect, register a delegate as follows:
Using this code in Unit Test:
using (var context = ShimsContext.Create()) { ShimJsonConvert.DeserializeObjectOf1String<SomeJSonObject>(s => new SomeJSonObject() { Name = "Foo" }); SomeJSonObject o = ConsoleApplication3.Program.Deserialize(); Assert.IsNotNull(o); Assert.AreSame(o.Name, "Foo"); }
And this verified code:
return JsonConvert.DeserializeObject<SomeJSonObject>("");
It works as expected for me.
If necessary, also register other overloads. Therefore, if you use some other overloads, you must also register the appropriate delegates in Shim:

how
ShimJsonConvert.DeserializeObjectOf1String<SomeJSonObject>(s => new SomeJSonObject() { Name = "Foo" }); ShimJsonConvert.DeserializeObjectOf1StringJsonConverterArray((s, convertors) => new SomeJSonObject() {Name = "Bar"}); ShimJsonConvert.DeserializeObjectOf1StringJsonSerializerSettings((s, settings) => new SomeJSonObject() { Name = "Bar" });
source share