Archive for January, 2009

Verifying indirect outputs with Rhino.Mocks in xUnit.BDDExtensions (2009-1-30)

This post by Sean Feldman was kind of an eye opener to me. It introduced me to a feature of Rhino.Mocks I wasn’t really aware of and helped to solve a problem I was never able to solve in a really satisfying way.

As you might know xUnit.BDDExtensions is using Rhino.Mocks behind the scenes, but [...]

ILMerge and Rake go xunit.BDDExtensions (2009-1-27)

Today I added this little piece of code to the trunk of xUnit.BDDExtensions. It’s a rake task for merging assemblies via the ILMerge tool.

desc "Merges the assemblies"
task :merge do
mkdir DEPLOY_DIR unless File.exists?(DEPLOY_DIR)
cp "xunit.dll".expand_to(:build_dir), "xunit.dll".expand_to(:deploy_dir)
cp "Rhino.Mocks.dll".expand_to(:build_dir), "Rhino.Mocks.dll".expand_to(:deploy_dir)
assemblies_to_merge = ["xUnit.BDDExtensions.dll", "StructureMap.dll", "StructureMap.AutoMocking.dll"]
ilmerge "xunit.bddextensions.dll", assemblies_to_merge
end

Ruby is a fantastic [...]

AutoMocking in xUnit.BDDExtensions (2009-1-26)

public class when_an_automatically_resolved_instance_with_a_single_dependency_is_used_in_a_fixture :
InstanceContextSpecification<ClassWithSingleDependency>
{
private object actualResult;
private IDependency dependency;
private object expectedResult;

protected override void EstablishContext()
{
expectedResult = new object();
dependency = AutoDependency<IDependency>();
dependency.WhenToldTo(x => x.Invoke()).Return(expectedResult);
}

protected override void Because()
{
actualResult = Sut.Invoke();
}

[Observation]
public void should_be_able_to_verify_calls_made_to_the_dependency()
{
dependency.WasToldTo(x => x.Invoke());
}

[Observation]
public void should_execute_the_configured_behavior_on_the_dependency()
{
actualResult.ShouldBeEqualTo(expectedResult);
}
}

This little feature was added to the trunk today. Yes, no CreateSut() call. You can omit it for most of the simple scenarios. You can [...]

Why Should you? (2009-1-23)

What’s the importance of Should in BDD? Why isn’t it called Must, Need to or Will?  It’s one of those subtle psychological things . . .
The main reason Dan North decided to use Should instead of all other  possibilities is, that Should implies that you can always question the behavior of your system. It isn’t [...]

Wording in BDD specs (2009-1-23)

Last week I had a little discussion on the german ALT.net mailing list in which I commented on a code example of a spec that wording in a BDD spec is of vital importance to BDD and therefore should be chosen very carefully. With this post I would like to clarify a bit what I [...]

Tales from hashes, null and boolean evaluation (2009-1-21)

A common programming situation when dealing with dictionary or hashtable classes is trying  to get a value from the hashtable and returning a default value in case nothing was found. In C# you could probably do it like this:

public class StringMapper : IMapper<string,string>
{
private IDictionary mapping; [...]

Using Rake to automate .NET builds (2009-1-19)

Today I started writing my first build scripts in Ruby for a .NET project using Rake. This is what I came up with.

require 'rake/clean'

EXTERNALS_DIR = File.expand_path('../Externals')
BUILD_DIR = File.expand_path('../Bin')
SOURCE_DIR = File.expand_path('../Source')

CLEAN.include(FileList[File.join(BUILD_DIR, '*')])

desc "Compiles the gemini sources"
task :build do
gemini_solution = File.join(SOURCE_DIR, 'Gemini.sln')
sh "msbuild /property:WarningLevel=4;OutDir=#{BUILD_DIR}/ #{gemini_solution}"
end

desc "Runs all the tests on the [...]

Yes, I’m still alive . . . (2009-1-19)

First of all: Happy new year to everyone. I know, I know, I’m really late with that
It’s been really quite on this blog for the last two month and I’m sorry for that. I’ve been busy changing a lot of things that caused me frustration and friction in my life as a software [...]