Unintended Call Count mutation for recursive mocks

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

    Posted 18 Nov 2013 Link to this post

    I have a recursive mock. I'm doing an arrangement on the child mock, but this has an unintended side effect in that the call count of the parent mock is incremented - this should not be happening.

    public interface IMyInterface
       IOther GetOther();
    public interface IOther
       int Foo(string test);
    public void TestMethod()
       var myInterface = Mock.Create<IMyInterface>();
       Mock.Assert(() => myInterface.GetOther(), Occurs.Never());
       Mock.Arrange(() => myInterface.GetOther().Foo(null)).IgnoreArguments().Returns(1);
       Mock.Assert(() => myInterface.GetOther(), Occurs.Never()); // BANG
  2. Kaloyan
    Kaloyan avatar
    878 posts

    Posted 18 Nov 2013 Link to this post

    Hi Isaac Abraham,

    Thank you for reporting this. We managed to reproduce the unwanted behavior thanks to your sample and indeed it seems like a bug in JustMock. It is now into our backlog in order to be fixed soon.

    As a token of gratitude, I have granted you some Telerik points.

    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