title: BDD for C# NUnit
body: <p>I've been using a home brewed BDD Spec extension for writing BDD style tests in NUnit, and I wanted to see what everyone thought. Does it add value? Does is suck? If so why? Is there something better out there?</p>
  
  <p>Here's the source:
  <a href="https://github.com/mjezzi/NSpec">https://github.com/mjezzi/NSpec</a></p>
  
  <p>There are two reasons I created this</p>
  
  <ol>
  <li>To make my tests easy to read.</li>
  <li>To produce a plain english output to
  review specs.</li>
  </ol>
  
  <p>Here's an example of how a test will look:</p>
  
  <p>-since zombies seem to be popular these days..</p>
  
  <p>Given a Zombie, Peson, and IWeapon:</p>
  
  <pre><code>namespace Project.Tests.PersonVsZombie
  {
      public class Zombie
      {
  
      }
  
      public interface IWeapon
      {
          void UseAgainst( Zombie zombie );
      }
  
      public class Person
      {
          private IWeapon _weapon;
  
          public bool IsStillAlive { get; set; }
  
          public Person( IWeapon weapon )
          {
              IsStillAlive = true;
              _weapon = weapon;
          }
  
          public void Attack( Zombie zombie )
          {
              if( _weapon != null )
                  _weapon.UseAgainst( zombie );
              else
                  IsStillAlive = false;
          }
      }
  }
  </code></pre>
  
  <p>And the NSpec styled tests:</p>
  
  <pre><code>public class PersonAttacksZombieTests
  {
      [Test]
      public void When_a_person_with_a_weapon_attacks_a_zombie()
      {
          var zombie = new Zombie();
          var weaponMock = new Mock&lt;IWeapon&gt;();
          var person = new Person( weaponMock.Object );
  
          person.Attack( zombie );
  
          "It should use the weapon against the zombie".ProveBy( spec =&gt;
              weaponMock.Verify( x =&gt; x.UseAgainst( zombie ), spec ) );
  
          "It should keep the person alive".ProveBy( spec =&gt;
              Assert.That( person.IsStillAlive, Is.True, spec ) );
      }
  
      [Test]
      public void When_a_person_without_a_weapon_attacks_a_zombie()
      {
          var zombie = new Zombie();
          var person = new Person( null );
  
          person.Attack( zombie );
  
          "It should cause the person to die".ProveBy( spec =&gt;
              Assert.That( person.IsStillAlive, Is.False, spec ) );
      }
  }
  </code></pre>
  
  <p>You'll get the Spec output in the output window:</p>
  
  <pre><code>[PersonVsZombie]
  
  - PersonAttacksZombieTests
  
      When a person with a weapon attacks a zombie
          It should use the weapon against the zombie
          It should keep the person alive
  
      When a person without a weapon attacks a zombie
          It should cause the person to die
  
  2 passed, 0 failed, 0 skipped, took 0.39 seconds (NUnit 2.5.5).
  </code></pre>