typemoq
typemoq copied to clipboard
Make IVerifies.verifialbe accept ExpectedCallType argument.
The current definition of IVerifies
is
export interface IVerifies {
verifiable(times?: Times): void;
}
The only implementation is in the MethodCall
class, where verifiable
is defined as:
verifiable(times?: all.Times, expectedCallType?: all.ExpectedCallType): void;
Because returns(f)
returns type IReturnsResult
, which only inherits IVerifies
, enabling the ExptectedCallType requires a cast:
`(mock.setup(m => m.func()).returns(() => retVal) as MethodCall<MockedType, MockedType>)
.verifiable(Times.once(), ExpectedCallType.InSequence);
Fixing the definition of IVerifies
would fix this problem.
I ran into this, today, too. You're left with casting like @ILMTitan does, above, or breaking the fluency, both of which worsen readability:
let msetup = this.mockDuplexer.setup(m => m.getAnswers(config));
msetup.returns(() => Promise[resolution](answers));
msetup.verifiable(Times.once(), ExpectedCallType.InSequence);
@florinn are you amenable to pull requests? This looks like it'd take but a few minutes. :-)