Thoughts on Technology, Methodology and Programming.

Archive for September, 2006

RSpec specifications in C#

Posted by Marcus Wyatt on 13 September 2006

Scott Bellware posted a very interesting article around using C# 3.0  Extension Method to create the same effect as Ruby Mixin to extend existing objects with new methods.

Basically, what I’m talking about is the ability to add a method to an object within a specific context without accessing the sourcecode. For example, add a ToCamelCase() method to the string object in .NET.

This may sound like a bit of voodoo and for someone who’s only ever coded in an strongly typed language, it will definably look that way. But dynamic languages like Ruby and Small talk has always had this behavior.

“Enough rambling man, show us some code”

Here is some of Scott’s examples:

NSpec in C# 2.0 NSpec in C# 3.0 with NSpec.Extensions
Specify.That(actual).ShouldEqual(expected) actual.ShouldEqual(expected)
Specify.That(actual).ShouldBeTheSameAs(expected) actual.ShouldBeTheSameAs(expected)
Specify.That(actual).ShouldNotBeTheSameAs(expected) actual.ShouldNotBeTheSameAs(expected)
Specify.That(value).ShouldBeTrue() value.ShouldBeTrue()
Specify.That(value).ShouldBeFalse() value.ShouldBeFalse()
Specify.ThrownBy(method) method.ThrownBy()
Specify.That(actual).ShouldBeOfType(expectedType) actual.ShouldBeOfType(expectedType)

Here’s Scott’s example of an NSpec specification written in C# 3.0 that used the extension methods. 

using NSpec.Framework;
// Import extension methods for NSpec
using NSpec.Extensions;
namespace Examples
    public class ExampleContext
        public void A_string_should_equal_another_string_when_both_strings_have_the_same_value()
            string s = "foo";

This is really cool, because now you can write your expectations naturally on the object or property that you want to validate.

tags: , , , ,

Currently listening to: Winamp *** 434. atb – drum n bass and beyond – prime

Posted in BDD, Development, TDD | 5 Comments »

Great BDD and rSpec Tutorial

Posted by Marcus Wyatt on 1 September 2006

Luke Redpath posted a great rSpec and Behavior-Driven Development tutorial that is one of the best I’ve read in awhile.


tags: , , ,

Currently listening to: DJ River / VA – DJ River – The Resolver (Winter 2006) [DJRiver.com]

Posted in BDD, RoR, TDD | Leave a Comment »

Some MSBuild Resources

Posted by Marcus Wyatt on 1 September 2006

Jeff Callahan - MSBuild Tester (rss)

MSBuild Reference on MSDN2

John Lam on MSBuild and in his newsletter (rss)

Robert Horvick on MSBuild (rss)

Jomo Fisher – MSBuild Developer (rss)

Mike Taulty:
MSBuild and Listing Tasks in VS.NET 2005 Beta 1, Getting Started with MSBuild

Jamie Cansdale on MSBuild (rss)

MSBuild Explorers Team WebLog (rss)

Alex Kipman - MSBuild PM (rss):
Differences between MSBuild and Ant, Targeting the 1.1 runtime with MSBuild, MSBuild and Monad

Christophe Nasarre on MSDN
Overview of MSBuild, Part 1: From a Project Author’s Perspective
Overview of MSBuild, Part 2: From the Task Author’s Perspective
Overview of MSBuild, Part 3: What Is the Limit to Extensibility?

GotDotNet User Sample: .NET Solution Build & Deployment Process & Tools
Update: There are lots of tasks for MSBuild 2.0 in here!

Klaus Aschenbrenner in Devx.com
Customize Your Builds in Visual Studio Using the Standalone MSBuild Tool

MSBuild 1.0 (from the PDC) Resources
MSBuild Documentation and Samples from the PDC
MSBuild Preview Quickstart Tutorials

MSBuild on MSDN TV
Visual Studio 2005: MSBuild Chat

A wiki with many more links:

MSBuild Wiki


tags: ,

Currently listening to: DJ River / VA – DJ River – The Blue Room (Spring 2006) [DJRiver.com]

Posted in Development | 1 Comment »


Get every new post delivered to your Inbox.