I’ve been working with MSpec lately. It’s a BDD framework for .Net. Here’s a hello world type example that uses Trace Writing to show a little bit about what it does.
using System;
using Machine.Specifications;
using System.Diagnostics;
namespace UnitedIndustrial.DataImportConcerns
{
[Subject("Sample")]
public class SampleConcerns
{
static string _myString;
Establish _context = () =>
{
_myString = "value from context";
LocationValueDump("context");
};
Because _of = () =>
{
_myString = "value from because";
LocationValueDump("because");
};
It _shouldKnow1And1Equals2 = () =>
{
(1 + 1).ShouldEqual(2);
LocationValueDump("_shouldKnow1And1Equals2");
};
It _shouldKnowANewStringIsNotNull = () =>
{
"hello".ShouldNotBeNull();
LocationValueDump("_shouldKnowANewStringIsNotNull");
};
private static void LocationValueDump(string location)
{
Trace.WriteLine(
String.Format("in {0} _myString is {1}",
location, _myString));
}
}
}