コード例 #1
0
        public void IsWithinBoundary(int x, int y, bool expectedResult)
        {
            var world        = new BoundedWorld(5, 5);
            var actualResult = world.IsWithinBoundary(new Coordinate(x, y));

            Assert.Equal(expectedResult, actualResult);
        }
コード例 #2
0
        public void EmptyCommandDoesnotMoveRover()
        {
            var rover = new Rover();
            var world = new BoundedWorld(5, 5);

            var commandModule = new CommandModule(rover, world.IsWithinBoundary);

            commandModule.Execute("", IgnoreErrors);

            Assert.Equal(0, rover.Location.X);
            Assert.Equal(0, rover.Location.Y);
        }
コード例 #3
0
        public void RoverFollowsCompleteCommandsToExpectedCoordinate(string command, int expectedX, int expectedY, Direction expectedDirection)
        {
            var rover = new Rover();
            var world = new BoundedWorld(5, 5);

            var commandModule = new CommandModule(rover, world.IsWithinBoundary);

            commandModule.Execute(command, IgnoreErrors);

            Assert.Equal(expectedX, rover.Location.X);
            Assert.Equal(expectedY, rover.Location.Y);
            Assert.Equal(expectedDirection, rover.Direction);
        }
コード例 #4
0
        public void RoverFollowsCompleteCommandsToExpectedCoordinateWithFailReportingPolicy(string command, int expectedX, int expectedY, Direction expectedDirection, bool errorsOccured)
        {
            var rover  = new Rover();
            var world  = new BoundedWorld(5, 5);
            var policy = new StopOnErrorPolicy();

            var commandModule = new CommandModule(rover, world.IsWithinBoundary);

            var errorHappened = false;

            commandModule.Execute(command, () => { errorHappened = true; return(false); });

            Assert.Equal(errorsOccured, errorHappened);
            Assert.Equal(expectedX, rover.Location.X);
            Assert.Equal(expectedY, rover.Location.Y);
            Assert.Equal(expectedDirection, rover.Direction);

            //commandModule.Execute(command, policy.StopOnError);
            //Assert.Equal(errorsOccured, policy.ErrorHappened);
        }