The Archives

SEARCH

I’m Attending

CodeMash

Tag Archives: typemock

Legacy Code Under Test Revisited and Working

Posted in: Programming by Steve on September 18, 2010

So after writing my last post, I was trying to look at it from a high level again.  The condition I was trying to determine was only if a single value on a parameter was set to a particular value.  In this case, my test was:

[Test]
public void user_added_to_position_sets_default_of_IsAssigned_equals_true_value()
{
  // test goes here
}

In essence, I want to verify that IsAssigned = true when it’s being saved for the first time.  In my last blog post, I was making sure that the entire entity matched instead of just this single value.  This devalued the test and didn’t test for the condition I was expecting. 

So I rewrote the assertion to look like this:

Isolate.Verify.WasCalledWithArguments(() => posUserRepo.Save(null, ref tran))
   .Matching(args => (((PositionUsersEntity) args[0]).IsAssigned));

Trying to make the test more simple ended up fixing my problem. 

Wrangling your Legacy Code

Posted in: Programming by Steve on September 17, 2010

I was working on getting a piece of legacy code under test.  I had all the pieces in place, refactored and set to go.  I tried to run a failing test and BOOM: the unexpected. 

The test failed, but for a reason that I can’t explain.  The entity that I was trying to verify was calling the database, even though I was not explicitly calling the database.  I actually had the whole transaction mocked.  However, when Typemock was trying to verify that something was called with an exact argument:

Isolate.Verify.WasCalledWithExactArguments(() => _posRepo.Save(pos, ref tran));

The “pos” entity was calling code that I didn’t want it to.  I went to debug the test to make sure I wasn’t crazy, and sure enough: this line of code was the culprit.  It didn’t have anything to do with the method I was testing, but one of the properties in the “pos” entity was calling the database.

My next course of action is to change the “pos” entity to a mocked entity to see if that will “fix the glitch” but I was rather upset that I was fighting the tooling instead of fixing the problem.  The code works, just not under test.

Typemock Isolator 5.3.1 and Automated Builds

Posted in: Programming by Steve on June 8, 2009

I recently upgraded to Typemock Isolator 5.3.1 and ran into a couple issues in my build.  From my post on getting Typemock to report results to TeamCity, we needed a few files included in the source control to get this working.  In version 5.3.1, we need a couple more files included.

For TeamCity to report on nUnit’s test results, here are the files that you will need:

  • Configuration.dll
  • exclude.dat (new for 5.3.1)
  • MockWeaver.dll
  • namespaces.dat
  • ProfileLinker.dll
  • Typemock.ArrangeActAssert.dll
  • Typemock.Configuration.exe
  • TypeMock.dll
  • Typemock.Interceptors.dll (new for 5.3.1)
  • Typemock.Isolator.VisualBasic.dll
  • TypeMock.NAntBuild.dll
  • typemockconfig.xml

After adding these 2 new files to my external libs directory, I was able to run my build script successfully.

Typemock ASP.NET Bundle Launch

Posted in: Programming by Steve on May 18, 2009

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.

Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle – and for the launch will be giving out FREE licenses to bloggers and their readers.
The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you’ll get a license automatically (even if more than 60 submit) during the first week of this announcement.

Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

Go ahead, click the following link for more information on how to get your free license.