Reputation: 4776
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
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