JazSharp
JazSharp copied to clipboard
Spies do not catch calls made via an interface
Describe<Adder>(() =>
{
// Expected behaviour
It("appends to history", () =>
{
OperationHistory history = new OperationHistory();
Spy historySpy = Jaz.SpyOn(history, nameof(history.Append));
var adder = new Adder(history);
adder.Add(-1, 1);
Expect(historySpy).ToHaveBeenCalled();
});
});
OperationHistory implements IOperationHistory. If Adder uses IoC (with an injected IOperationHistory rather than OperationHistory), the spy will not work:
Expected spy to have been called, but it wasn't.
See attached. LM.JazSharp.Examples-2.zip