1. Kevin Berridge
  2. RockPaperScissors

Source

RockPaperScissors / RockPaperScissors.Specs / GameSpecs.cs

Diff from to

File RockPaperScissors.Specs/GameSpecs.cs

     Because of = () =>
     {
       RockPaperScissors rps = new RockPaperScissors();
-      winner1 = rps.Play( "R", "S" );
-      winner2 = rps.Play( "S", "R" );
+      winner1 = rps.Play( Move.Rock, Move.Scissors );
+      winner2 = rps.Play( Move.Scissors, Move.Rock );
 
-      winner3 = rps.Play( "S", "P" );
-      winner4 = rps.Play( "P", "S" );
+      winner3 = rps.Play( Move.Scissors, Move.Paper );
+      winner4 = rps.Play( Move.Paper, Move.Scissors );
 
-      winner5 = rps.Play( "P", "R" );
-      winner6 = rps.Play( "R", "P" );
+      winner5 = rps.Play( Move.Paper, Move.Rock );
+      winner6 = rps.Play( Move.Rock, Move.Paper );
 
-      winner7 = rps.Play( "R", "R" );
-      winner8 = rps.Play( "S", "S" );
-      winner9 = rps.Play( "P", "P" );
+      winner7 = rps.Play( Move.Rock, Move.Rock );
+      winner8 = rps.Play( Move.Scissors, Move.Scissors );
+      winner9 = rps.Play( Move.Paper, Move.Paper );
     };
 
     It should_pick_rock_over_scissors = () =>
     It should_know_who_won = () =>
       whoWon.ShouldEqual( Player.First );
   }
+
+  [Subject( "Input" )]
+  public class when_converting_char_to_move
+  {
+    static Move R;
+    static Move Rlower;
+    static Move P;
+    static Move Plower;
+    static Move S;
+    static Move Slower;
+    static Exception caught;
+
+    Because of = () =>
+    {
+      R = InputConverter.Convert( 'R' );
+      Rlower = InputConverter.Convert( 'r' );
+
+      P = InputConverter.Convert( 'P' );
+      Plower = InputConverter.Convert( 'p' );
+
+      S = InputConverter.Convert( 'S' );
+      Slower = InputConverter.Convert( 's' );
+
+      caught = Catch.Exception( () => InputConverter.Convert( 'A' ) );
+    };
+
+    It should_convert_lower_or_upper_R_to_Rock = () =>
+    {
+      R.ShouldEqual( Move.Rock );
+      Rlower.ShouldEqual( Move.Rock );
+    };
+
+    It should_convert_lower_or_upper_P_to_Paper = () =>
+    {
+      P.ShouldEqual( Move.Paper );
+      Plower.ShouldEqual( Move.Paper );
+    };
+
+    It should_convert_lower_or_upper_S_to_Scissors = () =>
+    {
+      S.ShouldEqual( Move.Scissors );
+      Slower.ShouldEqual( Move.Scissors );
+    };
+
+    It should_throw_exception_otherwise = () => caught.ShouldBeOfType( typeof( ArgumentOutOfRangeException ) );
+  }
 }