Example #1
0
        public void Test_AddPlayer_SeatNotEmpty_ThrowsException()
        {
            Table table = new Table(4);

            table.AddPlayer(new Player(500, 0), 3);

            Exception exception = Assert.Throws <Exception>(() => table.AddPlayer(new Player(500, 0), 3));

            Assert.AreEqual(exception.Message, "Sorry, this seat has already a player");
        }
Example #2
0
        public void Test_RemovePlayer_DoesNotExist_ThrowsException()
        {
            Table table = new Table(4);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            Exception exception = Assert.Throws <Exception>(() => table.RemovePlayer(new Player(500, 0)));

            Assert.AreEqual(exception.Message, "This player is not sitting in the table");
        }
Example #3
0
        public void Test_RemovePlayer_FromSeatNumber_IsOk(int seatNumber)
        {
            Table table = new Table(4);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            Assert.DoesNotThrow(() => table.RemovePlayer(seatNumber));
        }
Example #4
0
        public void Test_RemovePlayer_FromNonExistingSeat_ThrowsException()
        {
            Table table = new Table(4);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            Exception exception = Assert.Throws <Exception>(() => table.RemovePlayer(8));

            Assert.AreEqual(exception.Message, "Sorry, seat not found");
        }
Example #5
0
        public void Test_RemovePlayer_FromEmptySeat_ThrowsException()
        {
            Table table = new Table(4);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            Exception exception = Assert.Throws <Exception>(() => table.RemovePlayer(3));

            Assert.AreEqual(exception.Message, "This seat is empty");
        }
Example #6
0
        public void Test_AddPlayer_TableAlreadyContainsPlayer_ThrowsException()
        {
            Table table  = new Table(4);
            var   player = new Player(500, 0);

            table.AddPlayer(player);

            Exception exception = Assert.Throws <Exception>(() => table.AddPlayer(player));

            Assert.AreEqual(exception.Message, "Sorry, selected player is already playing");
        }
Example #7
0
        public void Test_IsAnyEmpty_HasSomeEmptySeats_ReturnsTrue()
        {
            Table table = new Table(5);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            bool expected = table.Seats.IsAnyEmpty();

            Assert.AreEqual(expected, true);
        }
Example #8
0
        public void Test_StartGame_BoardStateIsPreFlop_IsTrue()
        {
            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            table.StartGame();

            Assert.AreEqual(table.Board.BoardState, BoardStateType.Preflop);
        }
Example #9
0
        public void Test_SetDealer_EmptySeat_ThrowsException()
        {
            Player playerDealer = new Player(500, 0);
            Table  table        = new Table(4, 0);

            table.AddPlayer(new Player(500, 0), 1);
            table.AddPlayer(new Player(500, 0), 3);
            table.AddPlayer(new Player(500, 0), 4);

            var exception = Assert.Throws <Exception>(() => table.SetDealer(2));

            Assert.AreEqual(exception.Message, "Sorry, selected seat is empty!");
        }
Example #10
0
        public void Test_AddPlayer_HasNoEmptySeats_ThrowsException()
        {
            Table table = new Table(4);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            Exception exception = Assert.Throws <Exception>(() => table.AddPlayer(new Player(500, 0)));

            Assert.AreEqual(exception.Message, "Sorry, no empty seat found");
        }
Example #11
0
        public void Test_Turn_BoardStateIsTurn_IsTrue()
        {
            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            table.StartGame();
            table.Flop();
            table.Turn();

            Assert.AreEqual(table.Board.BoardState, BoardStateType.Turn);
        }
Example #12
0
        public void Test_SetDealer_SpecificPlayer_IsOk()
        {
            Player playerDealer = new Player(500, 0);

            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0), 1);
            table.AddPlayer(playerDealer, 3);
            table.AddPlayer(new Player(500, 0), 4);

            table.SetDealer(3);

            Assert.IsTrue(playerDealer.IsDealer);
        }
Example #13
0
        public void Test_StartGame_WithPlayers_HaveCards(int seatNumber)
        {
            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            table.StartGame();

            bool expected = table.Players.ToList()[seatNumber].HasCards();

            Assert.AreEqual(expected, true);
        }
Example #14
0
        public void Test_SetDealer_SmallBlind_IsOk(int dealer, int smallBlind)
        {
            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0), 1);
            table.AddPlayer(new Player(500, 0), 3);
            table.AddPlayer(new Player(500, 0), 4);

            table.SetDealer(dealer);

            var expected = table.Seats[smallBlind].Player.IsSmallBlind;

            Assert.IsTrue(expected);
        }
Example #15
0
        public void Test_Turn_AfterStartGame_ThrowsException()
        {
            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            table.StartGame();

            Exception exception = Assert.Throws <Exception>(() => table.Turn());

            Assert.AreEqual(exception.Message, "The board has to go through Flop first!");
        }
Example #16
0
        public void Test_River_WhenInFlop_ThrowsException()
        {
            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));
            table.AddPlayer(new Player(500, 0));

            table.StartGame();
            table.Flop();

            Exception exception = Assert.Throws <Exception>(() => table.River());

            Assert.AreEqual(exception.Message, "The board has to go through Turn first!");
        }
Example #17
0
        public void Test_AddPlayer_SeatDoesNotExist_ThrowsException()
        {
            Table table = new Table(4);

            Exception exception = Assert.Throws <Exception>(() => table.AddPlayer(new Player(500, 0), 12));

            Assert.AreEqual(exception.Message, "Sorry, invalid seat number");
        }
Example #18
0
        public void Test_SetDealer_BigBlind_IsOk(int dealer, int bigBlind)
        {
            Player playerBigBlind = new Player(500, 0);

            Table table = new Table(4, 0);

            table.AddPlayer(new Player(500, 0), 1);
            table.AddPlayer(new Player(500, 0), 2);
            table.AddPlayer(playerBigBlind, 3);
            table.AddPlayer(new Player(500, 0), 4);

            table.SetDealer(dealer);

            var expected = table.Seats[bigBlind].Player.IsBigBlind;

            Assert.IsTrue(expected);
        }
Example #19
0
        public void Test_RemovePlayer_ByExistingPlayer_IsOk()
        {
            Table  table  = new Table(4);
            Player player = new Player(500, 0);

            table.AddPlayer(player);

            Assert.DoesNotThrow(() => table.RemovePlayer(player));
        }