Paulo Morgado

.NET Development & Architecture

Test Content

<p>Test</p>

This Blog

Syndication

Search

Sponsored By

Tags

Visitor Locations

<p><a href="http://www4.clustrmaps.com/counter/maps.php?url=http://PauloMorgado.NET/Blogs/EN" title="Visitor Locations"><img src="http://www4.clustrmaps.com/counter/index2.php?url=http://PauloMorgado.NET/Blogs/EN" alt="Visitor Locations" /></a></p>

News

Unit Test Today! Get Typemock Isolator!

Visitor Locations

Community

Email Notifications

Archives

TypeMock Insulator 4.2 Beta Publicly Available

TypeMock (now called) Insulator 4.2 Beta is publicly available. Check out the release notes.

One of my favorite new features is the improved mock chaining.

Take this class to be tested:

public class TestedClass1
{
    public IDictionary<string, object> Dictionary
    {
        get { throw new NotImplementedException(); }
    }

    public object Method(bool cond)
    {
        if (cond)
        {
            return Dictionary["true"];
        }
        else
        {
            return Dictionary["false"];
        }
    }
}

The following test:

[TestMethod]
[VerifyMocks]
public void TestMethod1()
{
    object trueObject = new object();
    object falseObject = new object();

    TestedClass1 target = RecorderManager.CreateMockedObject<TestedClass1>();

    using (RecordExpectations recorder = RecorderManager.StartRecording())
    {
        recorder.DefaultBehavior.CheckArguments();

        recorder.ExpectAndReturn(target.Dictionary["true"], trueObject);
        recorder.FailWhenCalled(target.Dictionary["false"]);
    }

    object value = target.Method(true);
    Assert.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.

Visual Studio cues are nice too.

Published Sun, Feb 3 2008 22:16 by Paulo Morgado

Comments

# Eli Lopian&#8217;s Blog (TypeMock) &raquo; Blog Archive &raquo; Typemock Isolator - Beta - Better Community@ Wednesday, February 06, 2008 5:56 PM

Pingback from  Eli Lopian&#8217;s Blog (TypeMock)  &raquo; Blog Archive   &raquo; Typemock Isolator - Beta - Better Community

Eli Lopian’s Blog (TypeMock) » Blog Archive » Typemock Isolator - Beta - Better Community

Leave a Comment

(required) 
(required) 
(optional)
(required)