Пример #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());
        }
Пример #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());
        }
Пример #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());
        }
Пример #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());
        }
Пример #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);
        }
Пример #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());
        }
Пример #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);
        }
Пример #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());
        }
Пример #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());
        }
Пример #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());
        }
Пример #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());
        }
Пример #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());
        }