Example #1
0
        public void DrawLetterTileTest()
        {
            bool exceptionWasThrown = false;

            Player player = new Player(1000, "Blob");
            Assert.IsTrue(player.TileRack.LetterTileCount() == 0);

            try
            {
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
            }
            catch
            {
                exceptionWasThrown = true;
            }
            Assert.IsFalse(exceptionWasThrown);
            exceptionWasThrown = false;
            Assert.IsTrue(player.TileRack.LetterTileCount() == 7);
            try
            {
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
            }
            catch
            {
                exceptionWasThrown = true;
            }
            Assert.IsTrue(exceptionWasThrown);
        }
Example #2
0
        public void PopLetterTileTest()
        {
            bool exceptionWasThrown = false;

            Player player = new Player(1000, "Blob");
            Assert.IsTrue(player.TileRack.LetterTileCount() == 0);

            try
            {
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
            }
            catch
            {
                exceptionWasThrown = true;
            }
            Assert.IsFalse(exceptionWasThrown);
            exceptionWasThrown = false;
            Assert.IsTrue(player.TileRack.LetterTileCount() == 7);
            try
            {
                player.DrawLetterTile(new Game_Objects.LetterTile('A', 1));
            }
            catch
            {
                exceptionWasThrown = true;
            }
            Assert.IsTrue(exceptionWasThrown);

            exceptionWasThrown = false;

            Game_Objects.LetterTile lt = new Game_Objects.LetterTile('E',1);
            try
            {
                lt = player.PopLetterTile(6);
            }
            catch
            {
                exceptionWasThrown = true;
            }

            Assert.IsFalse(exceptionWasThrown);
            Assert.IsTrue(lt.LetterValue == 'A');
            Assert.IsTrue(player.TileRack.LetterTileCount() == 6);

            try
            {
                player.PopLetterTile(5);
                player.PopLetterTile(4);
                player.PopLetterTile(3);
                player.PopLetterTile(2);
                player.PopLetterTile(1);
                player.PopLetterTile(0);
            }
            catch
            {
                exceptionWasThrown = true;
            }
            Assert.IsFalse(exceptionWasThrown);

            try
            {
                player.PopLetterTile(5);
            }
            catch
            {
                exceptionWasThrown = true;
            }
            Assert.IsTrue(exceptionWasThrown);
        }