chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi,

I'm using TypeMock 3.7.1 with .Net 2.0 and I'm trying to use DefaultBehavior.RepeatAlways() with chained natural mocks. I am getting the following exception that I don't think should be occuring:
Test method TestProject1.ProgramTest.method1Test threw exception: TypeMock.VerifyException: TypeMock Verification: Unexpected Call to MockintB.foo().

Here's some simple code to reproduce it. The code being tested is:
public static class classA
{
    public static intB B
    {
        get
        {
            return null;
        }
    }
}
public interface intB
{
    void foo();
    void bar();
}
public class MyClass
{
    public void method1()
    {
        classA.B.foo();
        classA.B.bar();
    }
}


And here is the unit test code:
[TestMethod()]
public void method1Test()
{
    using (RecordExpectations recorder = RecorderManager.StartRecording())
    {
        recorder.DefaultBehavior.RepeatAlways();
        classA.B.foo();
        classA.B.bar();
    }
    MyClass myClass = new MyClass();
    myClass.method1();
}


If I comment out the DefaultBehavior.RepeatAlways() then the test passes. However, in my real test I actually need the RepeatAlways behavior. Also, if I convert this to reflective mocks then it also passes (using ExpectAlways()).
asked by tibor (1.8k points)

3 Answers

0 votes
This is probably a Bug :twisted:
Thanks for reporting it.
We will send you a patch once we fix it.
answered by scott (32k points)
0 votes
Hi Tibor
I sent you the fix.
Please tell me if that solves your problem
answered by ohad (35.4k points)
0 votes
Hi
The patch is available to all in 4.0.0 release
answered by ohad (35.4k points)
...