RockPaperScissors / RockPaperScissors.Specs / GameSpecs.cs

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();
    };
  }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.