public void Should_remove_player_when_they_have_no_more_active_connections() { var persistanceService = new ChatPersistenceServiceWrapper(); var player = TestData.CreateRegularPlayer <Player_VM>(); var connectionId = Guid.NewGuid().ToString(); persistanceService.TrackConnection(player, connectionId); Assert.That(persistanceService.InternalPersistence[player.MembershipId].Connections, Has.Exactly(1).Items); persistanceService.TrackDisconnect(player.MembershipId, connectionId); Assert.That(persistanceService.InternalPersistence, Does.Not.ContainKey(player.MembershipId)); }
public void Should_remove_connection_on_disconnect() { var persistanceService = new ChatPersistenceServiceWrapper(); var player = TestData.CreateRegularPlayer <Player_VM>(); var connectionId1 = Guid.NewGuid().ToString(); var connectionId2 = Guid.NewGuid().ToString(); persistanceService.TrackConnection(player, connectionId1); persistanceService.TrackConnection(player, connectionId2); Assert.That(persistanceService.InternalPersistence[player.MembershipId].Connections, Has.Exactly(2).Items); persistanceService.TrackDisconnect(player.MembershipId, connectionId1); Assert.That(persistanceService.InternalPersistence[player.MembershipId].Connections, Has.Exactly(1).Items); Assert.That(persistanceService.InternalPersistence[player.MembershipId].Connections.First().ConnectionId, Is.EqualTo(connectionId2)); }