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); }
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); } }
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); }
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); }
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); } }
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); } }
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); } }