コード例 #1
0
        public void TestCanAction_5()
        {
            var         mock  = new Mock <IActionValidator>();
            IActionable robot = new TableRobot(mock.Object);

            Assert.AreEqual(false, robot.CanAction(ActionType.REPORT), "Report action cannot be taken before the robot gets placed onto the table.");
        }
コード例 #2
0
        public void TestCanAction_1()
        {
            var         mock  = new Mock <IActionValidator>();
            IActionable robot = new TableRobot(mock.Object);

            Assert.AreEqual(true, robot.CanAction(ActionType.PLACE), "Place action can always be taken.");
        }
コード例 #3
0
        public void TestToString()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            var result = robot.ToString();

            Assert.AreEqual("X: -1,  Y: -1,  Facing: NORTH", result, "Test Robot.ToString()");
        }
コード例 #4
0
        public void TestReport_1()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            var report = robot.Report();

            Assert.AreEqual(string.Empty, report, "Report action failed - No report before robot gets placed onto the table");
        }
コード例 #5
0
        public void TestCanAction_9()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 0, Facing.NORTH);

            Assert.AreEqual(true, robot.CanAction(ActionType.REPORT), "Report action can be taken after the robot gets placed onto the table.");
        }
コード例 #6
0
        public void TestReport_2()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 0, Facing.NORTH);

            var report = robot.Report();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: NORTH", report, "Report action successful");
        }
コード例 #7
0
        public void TestPlace_2()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 0, Facing.EAST);

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: EAST", newState, "Place action successful");
        }
コード例 #8
0
        public void TestToString()
        {
            var mock = new Mock <IActionValidator>();

            IActionable robot = new TableRobot(mock.Object);

            var result = robot.ToString();

            Assert.AreEqual("X: -1,  Y: -1,  Facing: NORTH", result, "Test Robot.ToString()");
        }
コード例 #9
0
        public void TestCanAction_9()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(true);
            IActionable robot = new TableRobot(mock.Object);

            robot.Place(0, 0, Facing.NORTH);

            Assert.AreEqual(true, robot.CanAction(ActionType.REPORT), "Report action can be taken after the robot gets placed onto the table.");
        }
コード例 #10
0
        public void TestReport_1()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(false);

            IActionable robot = new TableRobot(mock.Object);

            var report = robot.Report();

            Assert.AreEqual(string.Empty, report, "Report action failed when validation is not passed");
        }
コード例 #11
0
        public void TestMove_5()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 0, Facing.SOUTH);

            robot.Move();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: SOUTH", newState, "South move failed - outside table bottom edge");
        }
コード例 #12
0
        public void TestMove_4()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 1, Facing.SOUTH);

            robot.Move();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: SOUTH", newState, "South move successful");
        }
コード例 #13
0
        public void TestMove_3()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(4, 0, Facing.EAST);

            robot.Move();

            var newState = robot.ToString();

            Assert.AreEqual("X: 4,  Y: 0,  Facing: EAST", newState, "East move failed - outside table right edge");
        }
コード例 #14
0
        public void TestMove_6()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(1, 0, Facing.WEST);

            robot.Move();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: WEST", newState, "West move successful");
        }
コード例 #15
0
        public void TestRight_5()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 0, Facing.NORTH);

            robot.Right();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: EAST", newState, "Right action sucessful - from north to east");
        }
コード例 #16
0
        public void TestMove_1()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            var originalState = robot.ToString();

            robot.Move();

            var newState = robot.ToString();

            Assert.AreEqual(originalState, newState, "Move action failed - No move before robot gets placed onto the table");
        }
コード例 #17
0
        public void TestRight_4()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 0, Facing.WEST);

            robot.Right();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: NORTH", newState, "Right action sucessful - from west to north");
        }
コード例 #18
0
        public void TestPlace_1()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            var originalState = robot.ToString();

            robot.Place(5, 5, Facing.EAST);

            var newState = robot.ToString();

            Assert.AreEqual(originalState, newState, "Place action failed - outside table");
        }
コード例 #19
0
        public void TestMove_9()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            robot.Place(0, 4, Facing.NORTH);

            robot.Move();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 4,  Facing: NORTH", newState, "North move failed - outside table top edge");
        }
コード例 #20
0
        public void TestReport_2()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(true);

            IActionable robot = new TableRobot(mock.Object);

            robot.Place(1, 1, Facing.WEST);

            var report = robot.Report();

            Assert.AreEqual("X: 1,  Y: 1,  Facing: WEST", report, "Report action successful when validation is passed");
        }
コード例 #21
0
        public void TestMove_1()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(false);

            IActionable robot = new TableRobot(mock.Object);

            var originalState = robot.ToString();

            robot.Place(1, 1, Facing.EAST);

            var newState = robot.ToString();

            Assert.AreEqual(originalState, newState, "Move action is failed when validation is not passed");
        }
コード例 #22
0
        public void TestLeft_5()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(true);

            IActionable robot = new TableRobot(mock.Object);

            robot.Place(0, 0, Facing.EAST);

            robot.Left();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: NORTH", newState, "Left action sucessful - from east to north");
        }
コード例 #23
0
        public void TestMove_3()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(true);

            IActionable robot = new TableRobot(mock.Object);

            robot.Place(1, 1, Facing.SOUTH);

            robot.Move();

            var newState = robot.ToString();

            Assert.AreEqual("X: 1,  Y: 0,  Facing: SOUTH", newState, "Move action (south) is successfull when validation is passed");
        }
コード例 #24
0
        public void TestPlace_1()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(true);

            IActionable robot = new TableRobot(mock.Object);

            var originalState = robot.ToString();

            robot.Place(5, 5, Facing.EAST);

            var newState = robot.ToString();

            Assert.AreNotEqual(originalState, newState, "Place action is successfull when validation is passed");
            Assert.AreEqual("X: 5,  Y: 5,  Facing: EAST", newState, "Place action is successfull when validation is passed");
        }
コード例 #25
0
        public void TestRight_3()
        {
            var mock = new Mock <IActionValidator>();

            mock.Setup(m => m.Validate(It.IsAny <int>(), It.IsAny <int>())).Returns(true);

            IActionable robot = new TableRobot(mock.Object);


            robot.Place(0, 0, Facing.SOUTH);

            robot.Right();

            var newState = robot.ToString();

            Assert.AreEqual("X: 0,  Y: 0,  Facing: WEST", newState, "Right action sucessful - from south to west");
        }
コード例 #26
0
        public void TestCanAction_5()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            Assert.AreEqual(false, robot.CanAction(ActionType.REPORT), "Report action cannot be taken before the robot gets placed onto the table.");
        }
コード例 #27
0
        public void TestCanAction_1()
        {
            IActionable robot = new TableRobot(new FiveByFiveTableActionValidator());

            Assert.AreEqual(true, robot.CanAction(ActionType.PLACE), "Place action can always be taken.");
        }