コード例 #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");
        }
コード例 #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");
        }
コード例 #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));
        }
コード例 #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");
        }
コード例 #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");
        }
コード例 #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");
        }
コード例 #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);
        }
コード例 #8
0
ファイル: BoardTest.cs プロジェクト: sergiomamesa/Poker
        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);
        }
コード例 #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!");
        }
コード例 #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");
        }
コード例 #11
0
ファイル: BoardTest.cs プロジェクト: sergiomamesa/Poker
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #15
0
ファイル: BoardTest.cs プロジェクト: sergiomamesa/Poker
        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!");
        }
コード例 #16
0
ファイル: BoardTest.cs プロジェクト: sergiomamesa/Poker
        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!");
        }
コード例 #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");
        }
コード例 #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);
        }
コード例 #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));
        }