Esempio n. 1
0
        public void RotateRightLeftShouldNotChange(FigureType figureType)
        {
            var figureFactory = new FigureFactory();

            var figure = figureFactory.CreateStandardFigure(figureType);

            var newFigure = new Figure(figure);

            newFigure.Should().BeEquivalentTo(figure);

            newFigure.RotateLeft();
            newFigure.RotateRight();

            newFigure.Should().BeEquivalentTo(figure);

            newFigure.RotateRight();
            newFigure.RotateLeft();

            newFigure.Should().BeEquivalentTo(figure);
        }
Esempio n. 2
0
        public void RotateFigure()
        {
            //SUT:
            // Game:
            //   - field
            //   - figure
            // Game.RotateACW

            var game = new Game(new NextFigureFactoryStub());

            Tile TileF() => new Tile("Brown");

            game.Field = new Field(new Tile[, ]
            {
                // 0 -> Y
                // |
                // v X
                { TileF(), TileF(), TileF(), TileF(), TileF(), TileF(), TileF(), TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { null, null, null, null, null, null, null, TileF(), },
                { TileF(), TileF(), TileF(), TileF(), TileF(), TileF(), TileF(), TileF(), },
            });

            var figureFactory = new FigureFactory();

            var figure = figureFactory.CreateStandardFigure(FigureType.I);

            var notRotatedFigure = new Figure(figure);

            game.ResetFigure(figure).Should().BeTrue();

            game.Figure.Should().BeEquivalentTo(notRotatedFigure);

            game.RotateAntiClockWise();

            game.Figure.Should().NotBeEquivalentTo(notRotatedFigure);

            game.MoveLeft();
            game.RotateAntiClockWise();
            game.MoveLeft();
            game.RotateAntiClockWise();
            game.MoveLeft();
            game.RotateAntiClockWise();
            game.MoveLeft();
            game.RotateAntiClockWise();
            game.MoveLeft();
            game.RotateAntiClockWise();
            game.MoveLeft();

            // now the figure is at the most left
            // the wall should not let it rotate

            var figureAtLeftWallCopy = new Figure(game.Figure);

            game.RotateAntiClockWise();

            game.Figure.Should().BeEquivalentTo(figureAtLeftWallCopy);
        }