This is a migrated thread and some comments may be shown as answers.

Unintended Call Count mutation for recursive mocks

1 Answer 33 Views
JustMock Free Edition
This is a migrated thread and some comments may be shown as answers.
Isaac Abraham
Top achievements
Rank 1
Isaac Abraham asked on 18 Nov 2013, 01:23 PM
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);
}
 
[Fact]
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
}

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 18 Nov 2013, 01:52 PM
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.

Regards,
Kaloyan
Telerik
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.
Tags
JustMock Free Edition
Asked by
Isaac Abraham
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or