typemoq icon indicating copy to clipboard operation
typemoq copied to clipboard

Bug: Verify behaving strangely (maybe?)

Open Rasive opened this issue 6 years ago • 2 comments

I'm trying to mock a function, and then verify it gets called. I'm using the below code:

        // arrange
        const safeEvalMock:
            IMock<(string, any) => any> =
            Mock.ofInstance(() => It.isAny());

        const action = new Action(
            It.isAnyObject(undefined),
            safeEvalMock.object);

        action.precondition = It.isAnyString();
        action.goto = It.isAnyString();

        // act
        action.execute(It.isAny());

        // assert
        safeEvalMock.verify((x) =>
            x(It.isAnyString(), It.isAny()), Times.once());

The exception I'm getting sounds like it failed to call the function... but then it shows under performed invocation, that it actually did call the function, even thouh invocation is displayed as 0 times.

        MockException - invocation count verification failed (expected invocation of Function(It.isAnyString(),It.isAny()) exactly 1 times, invoked 0 times
        Configured setups:
        Function(It.isAnyString(),It.isAny())
        
        Performed invocations:
        Function(It.isAnyString(),It.isAny())

Did i misunderstand something, or is this a bug?

Rasive avatar Dec 09 '18 22:12 Rasive

I have the same problem. Function is called once but the verification fails.

przpl avatar Feb 25 '19 15:02 przpl

Same issue here :(

mct-dev avatar Jun 04 '20 21:06 mct-dev