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 There,

Apologise in advance if this has been answered elsewhere, but I have not been able to find any answers on the forums.

I have a method that I am trying to test and in the method it calls a static method on a static class.

Isolate.Fake.StaticConstructor(typeof(Resolver));
Isolate.Fake.StaticMethods(typeof(Resolver),Members.CallOriginal);
Isolate.WhenCalled(() => Resolver.Resolve<IRepository<WebSite>>()).WillReturn(fakeRepository);


But what I am seeing happen is that the original Static class and methods are still being called and I am receiving a NullReference exception.

I would have thought that I would need to swap the instance out with a fake instance, but not being able to create fakes of static types, I am unsure how to proceed.

Any help would be greatly appreciated.

Jarrod[/code]
asked by JMartin (600 points)

2 Answers

0 votes
Hi Jarrod,

Does the Resolver type belong to Autofac by a chance?

Also, please send us a small project reproducing the problem to support@typemock.com. This will help us in solving the problem.

Regards,
Yonatan
Typemock Support
answered by yonatan (1.6k points)
0 votes
i think u r right so i m also confused so u ger ans. then inform me.
thnak u
answered by sagarmendapara (180 points)
...