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(); }
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(); }
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 }); }
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"); }
public void GivenACasino_WhenGetTableThatDoesNotExist_ThenNullIsReturned() { var casino = new Casino(); var table = casino.GetTable(123); table.Should().BeNull(); }
public void GivenACasinoWithATable_WhenGetTable_ThenTheTableIsReturned() { var casino = new Casino(); var id = casino.CreateTable(); var table = casino.GetTable(id); table.Should().NotBeNull(); }
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()); }); }