Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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();
        }
Esempio n. 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());
        }
Esempio n. 5
0
        static void Print(Rover rover)
        {
            foreach (var item in rover.Movements)
            {
                Console.SetCursorPosition(item.X, item.Y);

                Console.Write("X");
            }
        }
Esempio n. 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();
         }
     }
 }
Esempio n. 8
0
        public void RoverCanReturnCurrentSatus(RoverState initialState)
        {
            var rover = new Rover.Rover(_fixture.map, initialState);

            Assert.True(initialState.Equals(rover.GetCurrentState()));
        }
Esempio n. 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());
 }
Esempio n. 10
0
 public NameRadar(string name, Environment env, Rover rover) : base(name, env, rover)
 {
 }
Esempio n. 11
0
 public MoveForwardCommand(Rover rover)
     : base(rover)
 {
 }
Esempio n. 12
0
 public LocationRadar(string name, Environment env, Rover rover) : base(name, env, rover)
 {
 }
Esempio n. 13
0
 public Radar(string name, Environment env, Rover rover) : base(name, USES_CHARGE, rover)
 {
 }
Esempio n. 14
0
 public RotateRightCommand(Rover rover)
     : base(rover)
 {
 }