Category: TDD

Migrating from NUnit to xUnit

These regular expression came in handy recently – they’re not perfect, in particular a couple of the second grouping need to be more greedy – but I did the migration first time through so didn’t get to improve them. Find: Assert.That((.+?), Is.EqualTo((.+?))) Replace: Assert.Equal($2, $1) Find: Assert.That((.+?) == (.+?)) Replace: Assert.Equal($2, $1) Find: Assert.That((.+?), Is.StringContaining((.+))) Replace: Assert.Contains($2, $1) Find: Assert.That((.+?).Contains((.+)))… Read more →

Multiple Dispatch, Double Dispatch and the Visitor Pattern

I’ve been looking into the Visitor pattern and figuring out how to make it work with overloaded methods. Starting with the abstractions interface IVisitor { void Visit(AbstractElement element); } abstract class AbstractElement { public void Accept(IVisitor visitor) { visitor.Visit(this); } } And initial implementations class TestElement1 : AbstractElement { } partial class TestVisitor1 : IVisitor { public string visitedMethod =… Read more →

TDD – getting started

It’s not TDD, it’s design by example http://stackoverflow.com/questions/2512504/tdd-how-to-start-really-thinking-tdd … I write a test that starts by ‘newing’ up a class that doesn’t exist. It won’t compile. (red) So, I create an empty class so it compiles, and succeeds. (green). I call a method on the class, it doesn’t yet exist and won’t compile. (red) I right click, “generate method”. Compile,… Read more →