Пример #1
0
        public void RoverCanMoveForward(RoverState initialState, RoverState expectedState)
        {
            var rover = new Rover.Rover(_fixture.map, initialState);

            rover.MoveForward();
            Assert.True(rover.GetCurrentState().Equals(expectedState));
        }
Пример #2
0
        public void RoverCanTrun(RoverState initialState, Rover.Rover.Turns turn, RoverState expectedState)
        {
            var rover = new Rover.Rover(_fixture.map, initialState);

            rover.Turn(turn);
            Assert.True(rover.GetCurrentState().Equals(expectedState));
        }
Пример #3
0
        static void Main(string[] args)
        {
            var plateau = new Plateau(5, 5);

            var dispatcher = new DefaultInstructionDispatcher();

            var rover1 = new Rover("Rover 1", plateau, new Position(1, 2, Direction.N));

            dispatcher.Dispatch(rover1, "LMLMLMLMM");

            var rover2 = new Rover("Rover 2", plateau, new Position(3, 3, Direction.E));

            dispatcher.Dispatch(rover2, "MMRMMRMRRM");

            Clear();

            Print(plateau);

            Print(rover1);

            Clear();

            //Print(plateau);

            //Print(rover2);

            Console.WriteLine(rover1);

            Console.WriteLine(rover2);

            Console.ReadLine();
        }
Пример #4
0
        public void RoverCanTrackCreationOutOfBoundarysError()
        {
            var x     = _fixture.map.maxX + 1;
            var y     = _fixture.map.maxY + 1;
            var rover = new Rover.Rover(_fixture.map, new RoverState(x, y, Directions.South));

            Assert.Equal($"({x},{y}) is out of map boundary.", rover.GetLastError());
        }
Пример #5
0
        static void Print(Rover rover)
        {
            foreach (var item in rover.Movements)
            {
                Console.SetCursorPosition(item.X, item.Y);

                Console.Write("X");
            }
        }
Пример #6
0
        public void RoverCanTrackMovingOutOfBoundaryError()
        {
            var rover = new Rover.Rover(_fixture.map, new RoverState(1, 1, Directions.South));

            rover.MoveForward();
            Assert.Null(rover.GetLastError());

            rover.MoveForward();
            Assert.Equal($"(1,{1 - 2}) is out of map boundary.", rover.GetLastError());
            //rover should stop moving when it's next step is out of boundary
            rover.MoveForward();
            Assert.Equal($"(1,{1 - 2}) is out of map boundary.", rover.GetLastError());
        }
 public void Dispatch(Rover rover, string instructions)
 {
     foreach (var instruction in instructions)
     {
         if (instruction == Move)
         {
             rover.Move();
         }
         else if (instruction == Left)
         {
             rover.Left();
         }
         else if (instruction == Right)
         {
             rover.Right();
         }
     }
 }
Пример #8
0
        public void RoverCanReturnCurrentSatus(RoverState initialState)
        {
            var rover = new Rover.Rover(_fixture.map, initialState);

            Assert.True(initialState.Equals(rover.GetCurrentState()));
        }
Пример #9
0
 static void Main(string[] args)
 {
     //Console.SetIn(new System.IO.StreamReader((System.IO.File.OpenRead("...")))); uncomment for test
     Rover rover = new Rover();
     Console.WriteLine(rover.Decide());
 }
Пример #10
0
 public NameRadar(string name, Environment env, Rover rover) : base(name, env, rover)
 {
 }
Пример #11
0
 public MoveForwardCommand(Rover rover)
     : base(rover)
 {
 }
Пример #12
0
 public LocationRadar(string name, Environment env, Rover rover) : base(name, env, rover)
 {
 }
Пример #13
0
 public Radar(string name, Environment env, Rover rover) : base(name, USES_CHARGE, rover)
 {
 }
Пример #14
0
 public RotateRightCommand(Rover rover)
     : base(rover)
 {
 }