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 GivenACasinoWithSomeTablesWithPlayers_WhenGetTablesForPlayer_ThenTheCorrectTablesAreReturned()
        {
            var casino = new Casino();
            var id1    = casino.CreateTable();
            var id2    = casino.CreateTable();
            var id3    = casino.CreateTable();

            casino.GetTable(id1).AddPlayer("Phil");
            casino.GetTable(id2).AddPlayer("Daniel");
            casino.GetTable(id3).AddPlayer("Phil");
            casino.GetTablesFor("Phil").Should().BeEquivalentTo(new [] { id1, id3 });
        }
Exemple #4
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 #5
0
        public void GivenACasino_WhenGetTableThatDoesNotExist_ThenNullIsReturned()
        {
            var casino = new Casino();
            var table  = casino.GetTable(123);

            table.Should().BeNull();
        }
Exemple #6
0
        public void GivenACasinoWithATable_WhenGetTable_ThenTheTableIsReturned()
        {
            var casino = new Casino();
            var id     = casino.CreateTable();
            var table  = casino.GetTable(id);

            table.Should().NotBeNull();
        }
Exemple #7
0
 public Task CreateTable()
 {
     return ActAndReportStatus(async () =>
     {
         var id = _casino.CreateTable();
         var table = _casino.GetTable(id);
         table.AddPlayer(Context.ConnectionId);
         await Groups.AddAsync(Context.ConnectionId, id.ToString());
     });
 }