Source

RockPaperScissors / RockPaperScissors.Specs / GameSpecs.cs

Full commit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Machine.Specifications;

namespace RockPaperScissors.Specs
{
  [Subject( "Game" )]
  public class when_playing_a_round
  {
    static Player winner1;
    static Player winner2;
    static Player winner3;
    static Player winner4;
    static Player winner5;
    static Player winner6;

    Because of = () =>
    {
      RockPaperScissors rps = new RockPaperScissors();
      winner1 = rps.Play( "R", "S" );
      winner2 = rps.Play( "S", "R" );

      winner3 = rps.Play( "S", "P" );
      winner4 = rps.Play( "P", "S" );

      winner5 = rps.Play( "P", "R" );
      winner6 = rps.Play( "R", "P" );
    };

    It should_pick_rock_over_scissors = () =>
    {
      winner1.ShouldEqual( Player.First );
      winner2.ShouldEqual( Player.Second );
    };

    It should_pick_scissors_over_paper = () =>
    {
      winner3.ShouldEqual( Player.First );
      winner4.ShouldEqual( Player.Second );
    };

    It should_pick_paper_over_rock = () =>
    {
      winner5.ShouldEqual( Player.First );
      winner6.ShouldEqual( Player.Second );
    };
  }

  public class with_stubs
  {
    protected static PromptUserStub _promptUserStub;
    protected static DisplayOutputStub _displayOutputStub;

    Establish context = () =>
    {
      _promptUserStub = new PromptUserStub();
      _displayOutputStub = new DisplayOutputStub();
    };
  }
}