main
  1using developwithpassion.bdd.contexts;
  2using developwithpassion.bdd.mbunit;
  3using developwithpassion.bdd.mbunit.standard.observations;
  4using mars.rover.domain;
  5
  6namespace specifications.domain
  7{
  8    public class RoverSpecs
  9    {
 10    }
 11
 12    public abstract class when_facing_north : observations_for_a_sut_without_a_contract<Rover>
 13    {
 14        public override Rover create_sut()
 15        {
 16            return new Rover(1, 2, Headings.North);
 17        }
 18    }
 19
 20    public abstract class when_facing_east : observations_for_a_sut_without_a_contract<Rover>
 21    {
 22        public override Rover create_sut()
 23        {
 24            return new Rover(1, 2, Headings.East);
 25        }
 26    }
 27
 28    public abstract class when_facing_west : observations_for_a_sut_without_a_contract<Rover>
 29    {
 30        public override Rover create_sut()
 31        {
 32            return new Rover(1, 2, Headings.West);
 33        }
 34    }
 35
 36    public abstract class when_facing_south : observations_for_a_sut_without_a_contract<Rover>
 37    {
 38        public override Rover create_sut()
 39        {
 40            return new Rover(1, 2, Headings.South);
 41        }
 42    }
 43
 44    public class when_a_rover_that_is_facing_north_is_told_to_turn_90_degrees_to_the_left : when_facing_north
 45    {
 46        it should_be_facing_west = () => sut.heading.should_be_equal_to(Headings.West);
 47
 48        because b = () => sut.turn_left();
 49    }
 50
 51    public class when_a_rover_that_is_facing_north_is_told_to_turn_90_degrees_to_the_right : when_facing_north
 52    {
 53        it should_be_facing_east = () => sut.heading.should_be_equal_to(Headings.East);
 54
 55        because b = () => sut.turn_right();
 56    }
 57
 58    public class when_a_rover_that_is_facing_east_is_told_to_turn_90_degrees_to_the_left : when_facing_east
 59    {
 60        it should_be_facing_north = () => sut.heading.should_be_equal_to(Headings.North);
 61
 62        because b = () => sut.turn_left();
 63    }
 64
 65    public class when_a_rover_that_is_facing_east_is_told_to_turn_90_degrees_to_the_right : when_facing_east
 66    {
 67        it should_be_facing_south = () => sut.heading.should_be_equal_to(Headings.South);
 68
 69        because b = () => sut.turn_right();
 70    }
 71
 72    public class when_a_rover_that_is_facing_south_is_told_to_turn_90_degrees_to_the_left : when_facing_south
 73    {
 74        it should_be_facing_east = () => sut.heading.should_be_equal_to(Headings.East);
 75
 76        because b = () => sut.turn_left();
 77    }
 78
 79    public class when_a_rover_that_is_facing_south_is_told_to_turn_90_degrees_to_the_right : when_facing_south
 80    {
 81        it should_be_facing_west = () => sut.heading.should_be_equal_to(Headings.West);
 82
 83        because b = () => sut.turn_right();
 84    }
 85
 86    public class when_a_rover_that_is_facing_west_is_told_to_turn_90_degrees_to_the_left : when_facing_west
 87    {
 88        it should_be_facing_south = () => sut.heading.should_be_equal_to(Headings.South);
 89
 90        because b = () => sut.turn_left();
 91    }
 92
 93    public class when_a_rover_that_is_facing_west_is_told_to_turn_90_degrees_to_the_right : when_facing_west
 94    {
 95        it should_be_facing_north = () => sut.heading.should_be_equal_to(Headings.North);
 96
 97        because b = () => sut.turn_right();
 98    }
 99
100    public class when_facing_north_and_moving_forward_one_grid_point : when_facing_north
101    {
102        it should_increment_its_y_coordinate = () => sut.y.should_be_equal_to<Coordinate>(3);
103
104        because b = () => sut.move_forward();
105    }
106
107    public class when_facing_south_and_moving_forward_one_grid_point : when_facing_south
108    {
109        it should_decrement_its_y_coordinate = () => sut.y.should_be_equal_to<Coordinate>(1);
110
111        because b = () => sut.move_forward();
112    }
113
114    public class when_facing_west_and_moving_forward_one_grid_point : when_facing_west
115    {
116        it should_decrement_its_x_coordinate = () => sut.x.should_be_equal_to<Coordinate>(0);
117
118        because b = () => sut.move_forward();
119    }
120
121    public class when_facing_east_and_moving_forward_one_grid_point : when_facing_east
122    {
123        it should_increment_its_x_coordinate = () => sut.x.should_be_equal_to<Coordinate>(2);
124
125        because b = () => sut.move_forward();
126    }
127}