Maris
Maris

Reputation: 4776

Fakeiteasy issue mocking soapclient

I'm trying to cover my business logic with unit tests using NUnit and fakeiteasy. But I suddenly stuck with faking calls to Soap client using fakeiteasy. I trying to do next thing

var myFakedSoapClient = A.Fake<SomeSoapClient>();
var myCustomServiceWhichUsesThatSoapClient = new MyService(myFakedSoapClient);
myCustomServiceWhichUsesThatSoapClient.CallDoSomething();   
myFakedSoapClient.CallsTo(e=>e.DoSomething(A<string>.Ignored)).MustHaveHappened();

But in the first row in which I'm trying to fake SoapClient it just get stuck and start to eat more and more memory. It doesn't show any exception, it just run that line until timeout.

What I miss?

Thx for any advance.

Upvotes: 1

Views: 454

Answers (1)

Sudipto Sarkar
Sudipto Sarkar

Reputation: 356

Include the fake call

myFakedSoapClient.CallsTo(e=>e.DoSomething(A<string>.Ignored)).WithAnyArgumemen().Returns(expectedfakeobject);

before the actual function call

var myCustomServiceWhichUsesThatSoapClient = new MyService(myFakedSoapClient);

Something like this

var myFakedSoapClient = A.Fake<SomeSoapClient>();
var myCustomServiceWhichUsesThatSoapClient = new MyService(myFakedSoapClient);
myFakedSoapClient.CallsTo(e=>e.DoSomething(A<string>.Ignored)).WithAnyArgumemen().Returns(expectedfakeobject);
myCustomServiceWhichUsesThatSoapClient.CallDoSomething();   
myFakedSoapClient.CallsTo(e=>e.DoSomething(A<string>.Ignored)).MustHaveHappened();

Upvotes: 1

Related Questions