Exemple #1
0
        public void GivenACasinoWithATableWithOnePlayer_WhenRemovePlayer_ThenThatTableIsRemoved()
        {
            var casino = new Casino();
            var id     = casino.CreateTable();
            var table  = casino.GetTable(id);

            table.AddPlayer("Phil");
            casino.RemovePlayer("Phil");
            casino.GetTable(id).Should().BeNull();
        }
Exemple #2
0
        public void GivenACasino_WhenRemovePlayerThatDoesNotExist_ThenNothingHappens()
        {
            var casino = new Casino();
            var id     = casino.CreateTable();

            casino.GetTable(id).AddPlayer("Daniel");
            casino.RemovePlayer("Phil");
            var table = casino.GetTable(id);

            table.Should().NotBeNull();
        }
Exemple #3
0
        public void GivenACasinoWithATableWithMultiplePlayers_WhenRemovePlayer_ThenThePlayerIsRemovedButNotTheTable()
        {
            var casino = new Casino();
            var id     = casino.CreateTable();

            casino.GetTable(id).AddPlayer("Phil");
            casino.GetTable(id).AddPlayer("Daniel");
            casino.RemovePlayer("Phil");
            var table = casino.GetTable(id);

            table.Should().NotBeNull();
            var status = table.GetStatus();

            status.Players.Should().HaveCount(1);
            status.Players.Should().Contain(p => p.Name == "Daniel");
        }
Exemple #4
0
        public override Task OnDisconnectedAsync(Exception exception)
        {
            _casino.RemovePlayer(Context.ConnectionId);

            return base.OnDisconnectedAsync(exception);
        }