Exemple #1
0
 public void Asks_if_deploy_point_is_valid_for_landing_surface()
 {
     var aPoint = new Point(0, 0);
     mockLandingSurface.Setup(x => x.IsValid(aPoint)).Returns(true);
     var rover = new Rover();
     rover.Deploy(mockLandingSurface.Object, aPoint, CardinalDirection.South);
     mockLandingSurface.Verify(x => x.IsValid(aPoint), Times.Once());
 }
            public void Composes_arguments_into_expected_report_format(int coordinateX, int coordinateY, CardinalDirection cardinalDirection, string expectedReport)
            {
                var point = new Point(coordinateX, coordinateY);

                var reportComposer = new ConsoleReportComposer();
                var report = reportComposer.Compose(point, cardinalDirection);
                Assert.AreEqual(expectedReport, report);
            }
 public string Compose(Point aPoint, CardinalDirection aCardinalDirection)
 {
     var reportItem1 = aPoint.X;
     var reportItem2 = aPoint.Y;
     var reportItem3 = cardinalDirectionDictionary[aCardinalDirection];
     var report = new StringBuilder();
     report.AppendFormat("{0} {1} {2}", reportItem1, reportItem2, reportItem3);
     return report.ToString();
 }
Exemple #4
0
            public void Given_valid_deploy_point_and_direction_exposes_as_properties(int expectedX, int expectedY, CardinalDirection expectedCardinalDirection)
            {
                var expectedPoint = new Point(expectedX, expectedY);
                mockLandingSurface.Setup(x => x.IsValid(expectedPoint)).Returns(true);

                var rover = new Rover();
                rover.Deploy(mockLandingSurface.Object, expectedPoint, expectedCardinalDirection);

                Assert.AreEqual(expectedPoint, rover.Position);
                Assert.AreEqual(expectedCardinalDirection, rover.CardinalDirection);
            }
Exemple #5
0
            public void Given_invalid_deploy_point_throws_RoverDeployException()
            {
                var aPoint = new Point(0, 0);
                var aSize = new Size(0, 0);

                mockLandingSurface.Setup(x => x.IsValid(aPoint)).Returns(false);
                mockLandingSurface.Setup(x => x.GetSize()).Returns(aSize);
                var rover = new Rover();

                Assert.Throws<RoverDeployException>(() =>
                    rover.Deploy(mockLandingSurface.Object, aPoint, CardinalDirection.West));
            }
Exemple #6
0
            public void After_Rover_has_been_deployed_returns_true()
            {
                var point = new Point(0, 0);
                mockLandingSurface.Setup(x => x.IsValid(point)).Returns(true);
                var rover = new Rover();
                rover.Deploy(mockLandingSurface.Object, point, CardinalDirection.North);

                var isDeployed = rover.IsDeployed();

                Assert.That(isDeployed);
            }
Exemple #7
0
            public void Alters_position_and_direction_in_response_to_movement_list(int startX, int startY, 
                CardinalDirection startDirection, Movement firstMove, Movement secondMove, Movement thirdMove, 
                int expectedX, int expectedY, CardinalDirection expectedDirection)
            {
                var startPosition = new Point(startX, startY);
                var expectedPosition = new Point(expectedX, expectedY);
                var movements = new List<Movement> {firstMove, secondMove, thirdMove};

                var mockLandingSurface = new Mock<ILandingSurface>();
                mockLandingSurface.Setup(x => x.IsValid(startPosition)).Returns(true);

                var rover = new Rover();
                rover.Deploy(mockLandingSurface.Object, startPosition, startDirection);
                rover.Move(movements);

                Assert.AreEqual(expectedPosition.X, rover.Position.X);
                Assert.AreEqual(expectedPosition.Y, rover.Position.Y);
                Assert.AreEqual(expectedDirection, rover.CardinalDirection);
            }
Exemple #8
0
            public void Before_Rover_has_been_deployed_returns_false()
            {
                var point = new Point(0, 0);
                mockLandingSurface.Setup(x => x.IsValid(point)).Returns(true);
                var rover = new Rover();

                var isDeployed = rover.IsDeployed();

                Assert.That(!isDeployed);
            }
 public RoverDeployCommand(Point aPoint, CardinalDirection aDirection)
 {
     DeployPoint = aPoint;
     DeployDirection = aDirection;
 }