public void DetectCollisionRotatingClockwiseBlankGrid()
        {
            var line = new ShapeI(new Point(5, 6));
            line.RotateClockWise();
            line.MoveRight();
            line.MoveRight();
            line.MoveRight();

            Assert.IsTrue(_detector.CollisionRotatingClockwise(line, new Dictionary<int, Tile>()), "Collision detection with right side of grid failed");

            line.MoveLeft();
            line.MoveLeft();
            line.MoveLeft();
            line.MoveLeft();
            line.MoveLeft();
            line.MoveLeft();

            Assert.IsTrue(_detector.CollisionRotatingClockwise(line, new Dictionary<int, Tile>()), "Collision detection with left side of grid failed");

            line.MoveRight();
            line.MoveRight();
            line.RotateClockWise();
            line.MoveDown();
            line.MoveDown();
            line.MoveDown();

            Assert.IsTrue(_detector.CollisionRotatingClockwise(line, new Dictionary<int, Tile>()), "Collision detection with bottom of grid failed");
        }
        public void RemoveCompletedRowIfRequired()
        {
            var line = new ShapeI(new Point(5, 1));
            var fallenTiles = new FallenTiles();

            foreach (var tile in line.Tiles)
                fallenTiles.Add(tile);
            foreach (var tile in new ShapeI(new Point(1, 2)).Tiles)
                fallenTiles.Add(tile);
            foreach (var tile in new ShapeI(new Point(1, 1)).Tiles)
                fallenTiles.Add(tile);

            int numberOfRowsRemoved;
            fallenTiles.RemoveCompletedRowIfRequired(line, 8, out numberOfRowsRemoved);

            // Assert 4 tiles remain i.e. 4 tiles have been removed (a row)
            Assert.AreEqual(4, fallenTiles.Tiles.Count);
            Assert.AreEqual(1, numberOfRowsRemoved);

            // Make sure the remaining tiles have shifted down
            Assert.IsTrue(fallenTiles.Tiles.ContainsKey(21));
            Assert.IsTrue(fallenTiles.Tiles.ContainsKey(22));
            Assert.IsTrue(fallenTiles.Tiles.ContainsKey(23));
            Assert.IsTrue(fallenTiles.Tiles.ContainsKey(24));
        }
 public void DetectDownNonCollisionFallenTiles()
 {
     var line = new ShapeI(new Point(1, 3));
     Assert.IsFalse(_detector.CollisionMovingDown(line, GetFallenTiles(3,7)));
 }
 private Dictionary<int, Tile> GetFallenTiles(int x, int y)
 {
     var fallenLine = new ShapeI(new Point(x, y));
     var fallenTiles = new Dictionary<int, Tile>();
     foreach (var tile in fallenLine.Tiles)
     {
         fallenTiles.Add(tile.Position.Index, tile);
     }
     return fallenTiles;
 }