hits counter

TypeMock Isolator 4.2 Released

TypeMock has released version 4.2 of its mocking framework: TypeMock Insulator. Check out the release notes.

My four favorite new features in this release are:

Improved mock chaining

(If you want to learn more about chains, read this post from Gil)

Take this class to be tested:

public class TestedClass1
{
    public IDictionary<string, object> Dictionary
    {
        get { throw new NotImplementedException(); }
    }
<span style="color: blue">public object </span>Method(<span style="color: blue">bool </span>cond)
{
    <span style="color: blue">if </span>(cond)
    {
        <span style="color: blue">return </span>Dictionary[<span style="color: #a31515">"true"</span>];
    }
    <span style="color: blue">else
    </span>{
        <span style="color: blue">return </span>Dictionary[<span style="color: #a31515">"false"</span>];
    }
}

}

The following test:

[TestMethod]
[VerifyMocks]
public void TestMethod1()
{
    object trueObject = new object();
    object falseObject = new object();
<span style="color: #2b91af">TestedClass1 </span>target = <span style="color: #2b91af">RecorderManager</span>.CreateMockedObject&lt;<span style="color: #2b91af">TestedClass1</span>&gt;();

<span style="color: blue">using </span>(<span style="color: #2b91af">RecordExpectations </span>recorder = <span style="color: #2b91af">RecorderManager</span>.StartRecording())
{
    recorder.DefaultBehavior.CheckArguments();

    recorder.ExpectAndReturn(target.Dictionary[<span style="color: #a31515">"true"</span>], trueObject);
    recorder.FailWhenCalled(target.Dictionary[<span style="color: #a31515">"false"</span>]);
}

<span style="color: blue">object </span>value = target.Method(<span style="color: blue">true</span>);
<span style="color: #2b91af">Assert</span>.AreEqual(trueObject, value);

}

Would simply fail with:

Test method TestProject1.UnitTest1.TestMethod1 threw exception:  TypeMock.VerifyException: 
TypeMock Verification: Method TestProject1.TestedClass1.get_Dictionary() has 1 more expected calls
.

Now, it just passes.

Debugger evaluation doesn't change the test behavior

Now you can debug your code without having to change your tests. You can query mocked values without influencing your tests.

You can do this and still have the test passing:

Debugger Support

The debugger can be run inside a recording block without confusing the test

You can now step into the recording block and debug it without affecting the recording process and the test.

Recording Block

When you step in the debugger into a mocked method, the mocked method will be painted

When you step into a mocked method (or property) I'll see that it's mocked.

Visual Studio Cues

No Comments