TypeMock is a Silver Bullet

During the TechEd in Bacelona, I overheard developers talking about TDD and Mocking. Then I heard one of them say that TypeMock is a Silver Bullet, it can just help you solve all your mocking problems. I love that, thanks guys.

Bookmark at:
Add 'TypeMock is a Silver Bullet' to Del.icio.us Add 'TypeMock is a Silver Bullet' to digg Add 'TypeMock is a Silver Bullet' to reddit Add 'TypeMock is a Silver Bullet' to Feed Me Links! Add 'TypeMock is a Silver Bullet' to Technorati Add 'TypeMock is a Silver Bullet' to Yahoo My Web Add 'TypeMock is a Silver Bullet' to Newsvine Add 'TypeMock is a Silver Bullet' to FURL Add 'TypeMock is a Silver Bullet' to blinklist Add 'TypeMock is a Silver Bullet' to My-Tuts 

12 November 2007 | .NET Tests | No Comments | Print This Post

Roys Test Name Convention

I just loved the way Roy explained how developers normally name their tests without really thinking about them. for example SumNegitiveNumber5 (yup, I have been down that road before) and his naming convention really make sense.

But what I really liked was the template he wrote and how the Tab key browses through the three the different parts of the name.

Bookmark at:
Add 'Roys Test Name Convention' to Del.icio.us Add 'Roys Test Name Convention' to digg Add 'Roys Test Name Convention' to reddit Add 'Roys Test Name Convention' to Feed Me Links! Add 'Roys Test Name Convention' to Technorati Add 'Roys Test Name Convention' to Yahoo My Web Add 'Roys Test Name Convention' to Newsvine Add 'Roys Test Name Convention' to FURL Add 'Roys Test Name Convention' to blinklist Add 'Roys Test Name Convention' to My-Tuts 

12 November 2007 | .NET Tests | No Comments | Print This Post

Rollback for database testing

Roy Osherove had a good speak in TechEd Barcelona 2007, about using the roll back attribute for database testing, and it works really well, keeping the test case isolated. Except in cases where the production code ignores transactions that are higher up in the hierarchy. This will happen if the TransactionOption is RequiresNew

Roy suggested to always use: Supported, but we believe that there should be a way to test you code even if you require and need to use another transactions.

So here is how I would do it with TypeMock.
I would create a new attribute for the rollback and make sure that all future TransactionOptions are Mocked.

This way our test will look like:

[TestMethod,Rollback,VerifyMocks]
public void MyDatabaseTest()
{
}

Here is the code, to enable this (for any test framework) simple add the attribute.

[AttributeUsage(AttributeTargets.Method)]
public sealed class RollBackAttribute : DecoratorAttribute

    public override object Execute() 
    { 
        // Start transaction
        ServiceConfig config = new ServiceConfig();
        config.Transaction = TransactionOption.RequiresNew;
        ServiceDomain.Enter(config);
        // make sure that all future Transactions rely on this transaction by mocking all sets to the Transaction
       Mock serviceConfigMock = MockManager.MockAll<ServiceConfig>(Constructor.NotMocked);
       serviceConfigMock.ExpectSetAlways("Transaction");

       try
       {
            // run our tests
           return base.CallDecoratedMethod(); 
        } finally
        { 
            // clear unused mocks
            serviceConfigMock.Clear();

             // rollback database
            if(ContextUtil.IsInTransaction)
            { 
                ContextUtil.SetAbort();
            }
            ServiceDomain.Leave();
        }
   } 
}

Bookmark at:
Add 'Rollback for database testing' to Del.icio.us Add 'Rollback for database testing' to digg Add 'Rollback for database testing' to reddit Add 'Rollback for database testing' to Feed Me Links! Add 'Rollback for database testing' to Technorati Add 'Rollback for database testing' to Yahoo My Web Add 'Rollback for database testing' to Newsvine Add 'Rollback for database testing' to FURL Add 'Rollback for database testing' to blinklist Add 'Rollback for database testing' to My-Tuts 

12 November 2007 | .NET Tests | No Comments | Print This Post

Moving to New Office

We have moved to our new offices. We are having a great time here. Here are some photos from the office and our ”Official Opening Party”

 P1010024  
Boxes of new hardware

P1010030
Amir and Efi Working…

P1010031
Mingling

P1010037 
Ohad, Gil and Lior

P1010041 
Ram and Yuval Neeman 

P1010042
We did have wine and whisky…

P1010047 
The TypeMock Experience
 
P1010048  
And here is a good one of me.

Bookmark at:
Add 'Moving to New Office' to Del.icio.us Add 'Moving to New Office' to digg Add 'Moving to New Office' to reddit Add 'Moving to New Office' to Feed Me Links! Add 'Moving to New Office' to Technorati Add 'Moving to New Office' to Yahoo My Web Add 'Moving to New Office' to Newsvine Add 'Moving to New Office' to FURL Add 'Moving to New Office' to blinklist Add 'Moving to New Office' to My-Tuts 

31 October 2007 | Uncategorized | 2 Comments | Print This Post

Going to TechEd Europe

We are going to TechEd Barcelona, although we don’t have a booth we going to have a TypeMock group meeting. The event will be announced (place and time) later on. 
If you wish to meet, please send your contact details.

Bookmark at:
Add 'Going to TechEd Europe' to Del.icio.us Add 'Going to TechEd Europe' to digg Add 'Going to TechEd Europe' to reddit Add 'Going to TechEd Europe' to Feed Me Links! Add 'Going to TechEd Europe' to Technorati Add 'Going to TechEd Europe' to Yahoo My Web Add 'Going to TechEd Europe' to Newsvine Add 'Going to TechEd Europe' to FURL Add 'Going to TechEd Europe' to blinklist Add 'Going to TechEd Europe' to My-Tuts 

31 October 2007 | Uncategorized | No Comments | Print This Post

The Ultimate Proof for TypeMock

When developer using TypeMock find it an indispensable tool, it is a sign that we really help ease the task of building lasting software.

Karell says it better:

The best way to see if you need something is to stop using it (or be prevented from using it) for a while and see if you reach out for it out of habit….

I quickly realized that TypeMock.NET had become such an important part of my testing process that I could no longer function without it. It is an indispensable tool and while I acquired another Mock tool I simply can’t do without TypeMock.NET.

Bookmark at:
Add 'The Ultimate Proof for TypeMock' to Del.icio.us Add 'The Ultimate Proof for TypeMock' to digg Add 'The Ultimate Proof for TypeMock' to reddit Add 'The Ultimate Proof for TypeMock' to Feed Me Links! Add 'The Ultimate Proof for TypeMock' to Technorati Add 'The Ultimate Proof for TypeMock' to Yahoo My Web Add 'The Ultimate Proof for TypeMock' to Newsvine Add 'The Ultimate Proof for TypeMock' to FURL Add 'The Ultimate Proof for TypeMock' to blinklist Add 'The Ultimate Proof for TypeMock' to My-Tuts 

31 October 2007 | Reviews, Product | No Comments | Print This Post

Mocking Extension Methods

With Orcas and TypeMock 4.1 you can now mock Extension methods, easily.

Suppose we added a new method to int that return the Roman Number equivalent of that number:

public static class Extend { public static string RomanNumber(this int number) { // do complex logic return romanString; } }


Now we use this method in our code

string romanNumber = 2010.RomanNumber();

Here is how we mock this.

Reflective Mocks (Community Edition)

We mock that actual static extension method

Mock extentionMethodMock = MockManager.Mock(typeof(Extend)); extentionMethodMock.ExpectAndReturn("RomanNumber","MCMLIX");

Natural Mocks (Professional Edition)

We just call the extension method

using (RecordExpectations rec = new RecordExpectations()) { rec.ExpectAndReturn( 2010.RomanNumber(), "MCMLIX"); }

Checking Arguments

Care should be taken when Checking Arguments as the first argument is the instance of the type we are extending, suppose the extension method takes another argument

public static class Extend { public static string RomanNumber(this int number, bool upperCase) { // do complex logic return romanString; } }
 

Here is how we validate the arguments.

Reflective Mocks (Community Edition)

We have to implicitly ignore the first argument

// first arg is instance, second must be false Mock extentionMethodMock = MockManager.Mock(typeof(Extend)); extentionMethodMock.ExpectAndReturn("RomanNumber","MCMLIX"). Args(Check.IsAny(),false);

Natural Mocks (Professional Edition)

TypeMock automatically handles the first argument

using (RecordExpectations rec = new RecordExpectations()) { // TypeMock knows that this is an extension method and ignores first argument automatically rec.ExpectAndReturn( 2010.RomanNumber(false), "MCMLIX") .CheckArguments(false); }
 

Bookmark at:
Add 'Mocking Extension Methods' to Del.icio.us Add 'Mocking Extension Methods' to digg Add 'Mocking Extension Methods' to reddit Add 'Mocking Extension Methods' to Feed Me Links! Add 'Mocking Extension Methods' to Technorati Add 'Mocking Extension Methods' to Yahoo My Web Add 'Mocking Extension Methods' to Newsvine Add 'Mocking Extension Methods' to FURL Add 'Mocking Extension Methods' to blinklist Add 'Mocking Extension Methods' to My-Tuts 

12 October 2007 | TDD, Product | No Comments | Print This Post

DotNetRocks Interview

I had a real fun talk with Richard and Carl on DotNetRocks. You can listen to the show here.

The highlight was a grand piano being delivered to Carl during the interview.  

Although the show was mainly targeted at Dependency Injections, there are many other design issues that are not required because TypeMock is design agnostic. One is the unnecessary need for virtual method Take a look at Jeremy’s post for more details.

Bookmark at:
Add 'DotNetRocks Interview' to Del.icio.us Add 'DotNetRocks Interview' to digg Add 'DotNetRocks Interview' to reddit Add 'DotNetRocks Interview' to Feed Me Links! Add 'DotNetRocks Interview' to Technorati Add 'DotNetRocks Interview' to Yahoo My Web Add 'DotNetRocks Interview' to Newsvine Add 'DotNetRocks Interview' to FURL Add 'DotNetRocks Interview' to blinklist Add 'DotNetRocks Interview' to My-Tuts 

12 October 2007 | TDD, .NET Tests | 2 Comments | Print This Post

NCover 2.0

imagePeter Waldschmidt has announced the release a new commercial version of NCover. NCover is now developed in  a new company called Gnoso. The new NCover is a complete Code Coverage Solution and combines Grant Drake’s NCoverExplorer

To use NCover 2.0 with TypeMock.NET, you will need to install TypeMock version 4.1. This now includes a option to link with NCover 2.0.
Now with Ncover 2.0 and TypeMock you can test and measure your 64 bit code! Both tools support 64 bit architectures and are integrated together.

Remember that all .NET 2.0+ code will run automatically in 64 bit and all .NET 1.1 code will always run in 32 bit mode.
To run .NET 2.0+ code in 32 bit, you must set the 32 bit flag of the executable.

Here is how:

corflags.exe /32BIT+ <path-to-executable>

Jamie has already created a TestDriven.Net version (2.9) that combines NCover 2.0 and TypeMock when running your tests.

Bookmark at:
Add 'NCover 2.0' to Del.icio.us Add 'NCover 2.0' to digg Add 'NCover 2.0' to reddit Add 'NCover 2.0' to Feed Me Links! Add 'NCover 2.0' to Technorati Add 'NCover 2.0' to Yahoo My Web Add 'NCover 2.0' to Newsvine Add 'NCover 2.0' to FURL Add 'NCover 2.0' to blinklist Add 'NCover 2.0' to My-Tuts 

12 October 2007 | Product | 2 Comments | Print This Post

TypeMock 4.1 Released

Syndicated from the TypeMock Announcement Forum.

We have released TypeMock 4.1.

A few of the new features included in this release are:
Arrow Support of .NET 3.5 syntax changes

Arrow Integration API for tools developers
New API was released to ease integrating TypeMock with other developer tools.

Arrow Tracer Enhancement (Professional Editions)
The tracer tool has been enhanced with the ability to pause and resume trace gathering, the ability to resize its different panes, and the marking of the start and end of each test.

Arrow NCover 2.0 Support (Professional Editions)
The new release of NCover tool (2.0.1) is now supported and can be linked to run with TypeMock
Arrow Support of Visual Studio Orcas Beta 2
TypeMock.NET can be run on Visual Studio Orcas Beta 2.
Arrow Many fixes

More information can be found in the Release Notes

Bookmark at:
Add 'TypeMock 4.1 Released' to Del.icio.us Add 'TypeMock 4.1 Released' to digg Add 'TypeMock 4.1 Released' to reddit Add 'TypeMock 4.1 Released' to Feed Me Links! Add 'TypeMock 4.1 Released' to Technorati Add 'TypeMock 4.1 Released' to Yahoo My Web Add 'TypeMock 4.1 Released' to Newsvine Add 'TypeMock 4.1 Released' to FURL Add 'TypeMock 4.1 Released' to blinklist Add 'TypeMock 4.1 Released' to My-Tuts 

12 October 2007 | Product | No Comments | Print This Post

Search Eli Lopian’s Blog (TypeMock)

Navigation

Recent Posts

Categories

Archives

Managment