Exemplo 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());
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }