Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Verify behaving strangely (maybe?) #118

Open
Rasive opened this issue Dec 9, 2018 · 2 comments
Open

Bug: Verify behaving strangely (maybe?) #118

Rasive opened this issue Dec 9, 2018 · 2 comments

Comments

@Rasive
Copy link

Rasive commented Dec 9, 2018

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?

@przpl
Copy link

przpl commented Feb 25, 2019

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

@mct-dev
Copy link

mct-dev commented Jun 4, 2020

Same issue here :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants