Esempio n. 1
0
        public void TestValidPlaceCommandDirection(string data)
        {
            var o       = new Simulator.Parser(Substitute.For <IRobot>());
            var command = "PLACE 1,1," + data;

            o.Parse(command);

            Assert.AreEqual(data, o.DResult.ToString());
        }
Esempio n. 2
0
        public void TestPlaceCommandWithInvalidFacing()
        {
            var o        = new Simulator.Parser(Substitute.For <IRobot>());
            var command  = "PLACE 0,0,INVALID";
            var expected = Simulator.CommandType.NOP;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void TestPlaceCommandWithWrongOrderParameters()
        {
            var o        = new Simulator.Parser(Substitute.For <IRobot>());
            var command  = "PLACE 0,NORTH,0";
            var expected = Simulator.CommandType.NOP;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void TestInvalidCommand()
        {
            var o        = new Simulator.Parser(Substitute.For <IRobot>());
            var command  = "INVALID";
            var expected = Simulator.CommandType.NOP;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        public void TestReportCommandBeforePlaceCommand()
        {
            var o        = new Simulator.Parser(Substitute.For <IRobot>());
            var command  = "REPORT";
            var expected = Simulator.CommandType.NOP;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        public void TestEmptyParse()
        {
            var o        = new Simulator.Parser(Substitute.For <IRobot>());
            var command  = string.Empty;
            var expected = Simulator.CommandType.NOP;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 7
0
        public void TestPlaceCommandCorrectCoordinates(int x, int y)
        {
            var o       = new Simulator.Parser(Substitute.For <IRobot>());
            var command = string.Format("PLACE {0},{1},NORTH", x, y);

            o.Parse(command);

            Assert.AreEqual(x, o.XResult);
            Assert.AreEqual(y, o.YResult);
        }
Esempio n. 8
0
        public void TestValidPlaceCommand(string data)
        {
            var o        = new Simulator.Parser(Substitute.For <IRobot>());
            var command  = "PLACE " + data;
            var expected = Simulator.CommandType.PLACE;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 9
0
        public void TestPlaceCommandWithIncorrectCoordinates(int x, int y)
        {
            var o        = new Simulator.Parser(Substitute.For <IRobot>());
            var command  = string.Format("PLACE {0},{1},NORTH", x, y);
            var expected = Simulator.CommandType.NOP;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 10
0
        public void TestReportCommandOnPlacedRobot()
        {
            var robot = Substitute.For <IRobot>();

            robot.X.Returns(2);
            robot.Y.Returns(2);
            robot.FacingDirection.Returns(Direction.EAST);
            var o        = new Simulator.Parser(robot);
            var command  = "Report";
            var expected = Simulator.CommandType.REPORT;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 11
0
        public void TestMoveCommandToMakeRobotFall(int x, int y, Direction d)
        {
            var robot = Substitute.For <IRobot>();

            robot.X.Returns(x);
            robot.Y.Returns(y);
            robot.FacingDirection.Returns(d);
            var o        = new Simulator.Parser(robot);
            var command  = "MOVE";
            var expected = Simulator.CommandType.NOP;

            var actual = o.Parse(command);

            Assert.AreEqual(expected, actual);
        }