typemoq icon indicating copy to clipboard operation
typemoq copied to clipboard

Make IVerifies.verifialbe accept ExpectedCallType argument.

Open ILMTitan opened this issue 7 years ago • 1 comments

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.

ILMTitan avatar Feb 07 '18 23:02 ILMTitan

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. :-)

cdibbs avatar May 12 '18 23:05 cdibbs