Esempio n. 1
0
        public void TestExecuteSetsCoordinatesAndDirectionOnPlace()
        {
            var robot = Substitute.For <IRobot>();
            var o     = new Simulator.Executor(robot);

            o.Execute(CommandType.PLACE, 0, 0, Direction.NORTH);
            robot.Received(1).X = 0;
            robot.Received(1).Y = 0;
            robot.Received(1).FacingDirection = Direction.NORTH;
        }
Esempio n. 2
0
        public void TestExecuteNotSetDirectionNorCoordinatesOnReport()
        {
            var robot = Substitute.For <IRobot>();

            robot.X.Returns(0);
            robot.Y.Returns(0);
            robot.FacingDirection.Returns(Direction.NORTH);
            var o = new Simulator.Executor(robot);

            o.Execute(CommandType.REPORT);

            robot.DidNotReceive().X = Arg.Any <int>();
            robot.DidNotReceive().Y = Arg.Any <int>();
            robot.DidNotReceive().FacingDirection = Arg.Any <Direction>();
        }
Esempio n. 3
0
        public void TestExecuteSetsDirectionAndNotCoordinatesOnRight()
        {
            var robot = Substitute.For <IRobot>();

            robot.X.Returns(0);
            robot.Y.Returns(0);
            robot.FacingDirection.Returns(Direction.NORTH);
            var o = new Simulator.Executor(robot);

            o.Execute(CommandType.RIGHT);

            robot.DidNotReceive().X = Arg.Any <int>();
            robot.DidNotReceive().Y = Arg.Any <int>();
            robot.Received(1).FacingDirection = Direction.EAST;
        }
Esempio n. 4
0
        public void TestExecuteSetsCoordinatesAndNotDirectionOnMove()
        {
            var robot = Substitute.For <IRobot>();

            robot.X.Returns(0);
            robot.Y.Returns(0);
            robot.FacingDirection.Returns(Direction.NORTH);
            var o = new Simulator.Executor(robot);

            o.Execute(CommandType.MOVE);

            robot.Received(1).X = 0;
            robot.Received(1).Y = 1;
            robot.DidNotReceive().FacingDirection = Arg.Any <Direction>();
        }
Esempio n. 5
0
        public void TestExecuteReport()
        {
            var robot = Substitute.For <IRobot>();

            robot.X.Returns(0);
            robot.Y.Returns(0);
            robot.FacingDirection.Returns(Direction.NORTH);
            var o        = new Simulator.Executor(robot);
            var actual   = string.Empty;
            var expected = "0,0,NORTH";

            o.WriteLine = (s) => actual = s;

            o.Execute(CommandType.REPORT);

            Assert.AreEqual(expected, actual);
        }