コード例 #1
0
        public void Figure_ShouldNotRotate_WhenNearBorder()
        {
            var game   = new GameModel(new Size(10, 20));
            var figure = Tetromino.CreateFigure(FigureType.S, new Vector(0, 0));

            game.StartGame();
            Assert.AreEqual(game.CanRotateFigure(figure), false);
        }
コード例 #2
0
ファイル: TetrominoTests.cs プロジェクト: Aceki/Tetris
 public void Tetromino_CreatesCorrectFigures()
 {
     for (var i = 0; i < 7; i++)
     {
         var figureType = (FigureType)i;
         var figure     = Tetromino.CreateFigure(figureType, new Vector(0, 0));
         Assert.AreEqual(figure.Type, figureType);
     }
 }
コード例 #3
0
ファイル: GameTests.cs プロジェクト: Aceki/Tetris
        public void GameOver_WhenPlaceBlockOnTop()
        {
            var game   = new GameModel(new Size(10, 20));
            var figure = Tetromino.CreateFigure(FigureType.O, new Vector(0, -Block.Size * 2));

            game.StartGame();
            game.AddToGameField(figure);
            Assert.AreEqual(game.GameIsOver, true);
        }
コード例 #4
0
ファイル: FigureMoveTests.cs プロジェクト: Aceki/Tetris
        public void FigureMoveToDown_ShouldNotLeaveGameField()
        {
            var fieldSize = new Size(10, 20);
            var game      = new GameModel(fieldSize);

            game.StartGame();
            var figure = Tetromino.CreateFigure(FigureType.O, new Vector(0, Block.Size * 18));

            Assert.AreEqual(game.CanMoveFigureTo(Direction.Down, figure), false);
        }
コード例 #5
0
        public void FigureTypeO_ShouldNotRotate()
        {
            var figure = Tetromino.CreateFigure(FigureType.O, new Vector(Block.Size * 2, Block.Size * 2));
            var startBlocksPositions = figure.Blocks.Select(b => b.Position).ToArray();

            figure.Rotate();
            for (var i = 0; i < figure.Blocks.Length; i++)
            {
                Assert.AreEqual(startBlocksPositions[i], figure.Blocks[i].Position);
            }
        }
コード例 #6
0
ファイル: FigureMoveTests.cs プロジェクト: Aceki/Tetris
        public void FigureMoveToUp_ShouldMoveFigureToUp()
        {
            var figure         = Tetromino.CreateFigure(FigureType.O, new Vector(0, 0));
            var startPositions = figure.Blocks.Select(b => b.Position).ToArray();

            figure.MoveTo(Direction.Up);
            for (var i = 0; i < figure.Blocks.Length; i++)
            {
                Assert.AreEqual(startPositions[i].X, figure.Blocks[i].Position.X);
                Assert.AreEqual(startPositions[i].Y - Block.Size, figure.Blocks[i].Position.Y);
            }
        }
コード例 #7
0
ファイル: GameTests.cs プロジェクト: Aceki/Tetris
        public void GameGetBlockFromField_WorksCorrect()
        {
            var game   = new GameModel(new Size(10, 20));
            var figure = Tetromino.CreateFigure(FigureType.O, new Vector(0, Block.Size * 2));

            game.StartGame();
            game.AddToGameField(figure);
            var blockFromField = game.GetBlocksFromField();

            foreach (var block in figure.Blocks)
            {
                Assert.AreEqual(blockFromField.Contains(block), true);
            }
        }