Beispiel #1
0
        void RobotService_Left_Placed_Allowed(Facing start, Facing expected, [Frozen]Mock<IRobot> mockRobot, RobotService sut)
        {
            mockRobot.SetupProperty(x => x.Placed, true);
            mockRobot.SetupProperty(x => x.F, start);

            sut.Left();

            mockRobot.VerifySet(r => r.F = expected, Times.Once());
        }
Beispiel #2
0
        void RobotService_Left_NotPlaced_Ignored(Facing start, Facing expected, [Frozen]Mock<IRobot> mockRobot, RobotService sut)
        {
            mockRobot.SetupProperty(x => x.Placed, false);
            mockRobot.SetupProperty(x => x.F, start);

            sut.Left();

            mockRobot.VerifySet(r => r.F = expected, Times.Never());
        }
Beispiel #3
0
        void RobotService_MoveNorth_PlacedAndValid_Allowed(int tableWidth, int tableHeight,
            [Frozen] Mock<ITable> mockTable, [Frozen] Mock<IRobot> mockRobot, RobotService sut)
        {
            mockTable.SetupTableFixture(tableWidth, tableHeight);
            mockRobot.SetupRobotFixture(tableWidth - 2, tableHeight - 2, Facing.NORTH, true);

            sut.Move();

            mockRobot.VerifySet(r => r.Y = tableHeight - 1, Times.Once());
        }
Beispiel #4
0
        void RobotService_MoveEast_PlacedNotValid_Ignored(int tableWidth, int tableHeight,
            [Frozen] Mock<ITable> mockTable, [Frozen] Mock<IRobot> mockRobot, RobotService sut)
        {
            mockTable.SetupTableFixture(tableWidth, tableHeight);
            mockRobot.SetupRobotFixture(tableWidth - 1, tableHeight - 1, Facing.EAST, true);

            sut.Move();

            mockRobot.VerifySet(r => r.X = It.IsAny<int>(), Times.Never());
        }
Beispiel #5
0
        void RobotService_Report_Placed_Allowed(int x, int y, Facing f, string expected, [Frozen]Mock<IRobot> mockRobot, 
            RobotService sut)
        {
            mockRobot.SetupRobotFixture(x, y, f, true);

            Assert.True(sut.Report() == expected);
        }
Beispiel #6
0
        void RobotService_Place_ValidPlacement_Allowed(int x, int y, Facing f, int tableWidth, int tableHeight, 
            [Frozen]Mock<IRobot> mockRobot, [Frozen]Mock<ITable> mockTable, RobotService sut)
        {
            mockTable.SetupTableFixture(tableWidth, tableHeight);

            sut.Place(x, y, f);

            mockTable.VerifyGet(t => t.Width, Times.AtLeastOnce());
            mockTable.VerifyGet(t => t.Height, Times.AtLeastOnce());

            mockRobot.VerifySet(r => r.X = x, Times.Once());
            mockRobot.VerifySet(r => r.Y = y, Times.Once());
            mockRobot.VerifySet(r => r.F = f, Times.Once());
            mockRobot.VerifySet(r => r.Placed = true, Times.Once());
        }
Beispiel #7
0
        void RobotService_Report_NotPlaced_Ignored(int x, int y, Facing f, [Frozen] Mock<IRobot> mockRobot,
            RobotService sut)
        {
            mockRobot.SetupRobotFixture(x, y, f, false);

            Assert.True(sut.Report() == string.Empty);
        }
Beispiel #8
0
        void RobotService_Place_InvalidPlacement_Ignored(int x, int y, Facing f, int tableWidth, int tableHeight, [Frozen] Mock<IRobot> mockRobot,
            [Frozen] Mock<ITable> mockTable, RobotService sut)
        {
            mockTable.SetupTableFixture(tableWidth, tableHeight);

            sut.Place(x, y, f);

            mockTable.VerifyGet(t => t.Width, Times.AtLeastOnce());
            mockTable.VerifyGet(t => t.Height, Times.AtLeastOnce());

            mockRobot.VerifySet(r => r.X = It.IsAny<int>(), Times.Never());
            mockRobot.VerifySet(r => r.Y = It.IsAny<int>(), Times.Never());
            mockRobot.VerifySet(r => r.F = It.IsAny<Facing>(), Times.Never());
            mockRobot.VerifySet(r => r.Placed = It.IsAny<bool>(), Times.Never());
        }
Beispiel #9
0
        void RobotService_Move_NotPlacedButValid_Ignored(Facing f, int tableWidth, int tableHeight,
            [Frozen] Mock<ITable> mockTable, [Frozen] Mock<IRobot> mockRobot, RobotService sut)
        {
            mockTable.SetupTableFixture(tableWidth, tableHeight);
            mockRobot.SetupRobotFixture(1, 1, f, false);

            sut.Move();

            mockRobot.VerifySet(r => r.X = It.IsAny<int>(), Times.Never());
            mockRobot.VerifySet(r => r.Y = It.IsAny<int>(), Times.Never());
        }
Beispiel #10
0
        void RobotService_MoveWest_PlacedWestEdge_Ignored([Frozen]Mock<IRobot> mockRobot, RobotService sut)
        {
            mockRobot.SetupRobotFixture(0, 0, Facing.WEST, true);

            sut.Move();

            mockRobot.VerifySet(r => r.X = It.IsAny<int>(), Times.Never());
        }
Beispiel #11
0
        void RobotService_MoveWest_PlacedAndValid_Allowed([Frozen]Mock<IRobot> mockRobot, RobotService sut)
        {
            mockRobot.SetupRobotFixture(1, 0, Facing.WEST, true);

            sut.Move();

            mockRobot.VerifySet(r => r.X = 0, Times.Once());
        }
Beispiel #12
0
        void RobotService_MoveSouth_PlacedAndValid_Allowed([Frozen]Mock<IRobot> mockRobot, RobotService sut)
        {
            mockRobot.SetupRobotFixture(0, 1, Facing.SOUTH, true);

            sut.Move();

            mockRobot.VerifySet(r => r.Y = 0, Times.Once());
        }