Exemplo n.º 1
0
        public void SnakeGame_PlaceNextPiece()
        {
            Position head = new Position(), tail = new Position();

            eCellType[] field = new eCellType[64];

            FieldMatrix.Seed(field, head, tail);
            var rnd = new Random();

            while (field.Any(f => f == eCellType.None))
            {
                var currentEmpty = field.Count(f => f == eCellType.None);

                FieldMatrix.PlaceNextPiece(field, (byte)rnd.Next());

                var nextEmpty = field.Count(f => f == eCellType.None);

                Assert.AreEqual(currentEmpty - 1, nextEmpty, "Did not place next piece");
            }

            Assert.ThrowsException <GameCompletedException>(() => FieldMatrix.PlaceNextPiece(field, 10));
        }