Given I have a wrapped instance like this, where Resolve method injects dependencies
var handler = this.Resolve<DeletePaymentCardHandler>();
var wrapperHandler = A.Fake<DeletePaymentCardHandler>(
o => o.Wrapping(handler));
A.CallTo(() => wrapperHandler.EnsurePaymentCardCanBeDeleted(A<DeletePaymentCard>._, A<CancellationToken>._ ))
.Returns(Task.CompletedTask);
await wrapperHandler.Handle(command, CancellationToken.None);
Where 'Handle' method is implemented like this
public async Task Handle(DeletePaymentCard msg, CancellationToken cancellationToken)
{
await this.EnsurePaymentCardCanBeDeleted(msg, cancellationToken);
var instance = await this.repository.GetById<Domain.CustomerFundingSources>(msg.CustomerId, cancellationToken);
instance.Process(msg);
await this.repository.Save(instance);
}
public virtual async Task EnsurePaymentCardCanBeDeleted(DeletePaymentCard command, CancellationToken cancellationToken)
{
return Task.CompletedTask
}
What I am observing is that instead of this call in Handle calling injected repository it calls proxy created by FakeItEasy?
var instance = await this.repository.GetById<Domain.CustomerFundingSources>(msg.CustomerId, cancellationToken);
I thought point was to be able to intercept only calls to some methods and rest should call wrapped instance methods? From documentation:
"By default, calls to a wrapping fake that have not been explicitly configured will be forwarded to the wrapped object."