Assert calls DoInsert implicitly

2 posts, 0 answers
  1. Isaac Abraham
    Isaac Abraham avatar
    21 posts
    Member since:
    Sep 2009

    Posted 25 Apr 2013 Link to this post

    I have a mock and have set up a call to DoInstead on it, something like this: -

    Mock.Arrange(() => myService.Foo(Arg.AnyGuid))
       .DoInstead(new System.Action<System.Guid>(Console.WriteLine));

    Later on in my test, I call an Assert on that same method: -

    Mock.Assert(() => myService.Foo(Arg.AnyGuid), Occurs.Once());

    When it hits the Assert line, my DoInstead handler suddenly gets fired. It's as if the Assertion is actually called the mock method like my production code has. Even worse, if I put a Match on the Arrange call e.g.

    myService.Foo(Arg.Matches<Guid>(g => g != Guid.Empty))

    but this is completely ignored and it still falls into the Console.WriteLine call.

    At any rate, calls to Assert should not implicitly call DoInstead handlers that have already been set up.
  2. Kaloyan
    Kaloyan avatar
    878 posts

    Posted 30 Apr 2013 Link to this post

    Hi Isaac,

    Thank you for reporting these issues.

    Our development team is currently working on them. Fixes should be expected in one of the JustMock near future releases.

    For reporting a critical bug, we have granted you some Telerik points.

    Kind regards,
    the Telerik team
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
Back to Top