private static IEnumerable <IScene> GetAvailableScenes(string roomId, SynchronizedRooms rooms, IReadOnlyList <IScene> scenes) { var presenterScenes = scenes.OfType <PresenterScene>(); return(presenterScenes.Where(x => rooms.Participants.TryGetValue(x.PresenterParticipantId, out var presenterRoomId) && presenterRoomId == roomId)); }
public void GetParticipantsOfRoom_EmptyParticipants_ReturnEmpty() { // arrange var rooms = new SynchronizedRooms(ImmutableList <Room> .Empty, "d", ImmutableDictionary <string, string> .Empty); // act var result = SceneUtilities.GetParticipantsOfRoom(rooms, "test"); // assert Assert.Empty(result); }
public void ParticipantsOfRoomChanged_PreviousValueNull_ReturnTrue() { // arrange var current = new SynchronizedRooms(ImmutableList <Room> .Empty, "default", ImmutableDictionary <string, string> .Empty); SynchronizedRooms?previous = null; // act var result = SceneUtilities.ParticipantsOfRoomChanged("room1", current, previous); // assert Assert.True(result); }
public static bool ParticipantsOfRoomChanged(string roomId, SynchronizedRooms rooms, SynchronizedRooms?previousRooms) { if (previousRooms == null) { return(true); } var roomsParticipants = GetParticipantsOfRoom(rooms, roomId); var previousRoomsParticipants = GetParticipantsOfRoom(previousRooms, roomId); return(!roomsParticipants.SequenceEqual(previousRoomsParticipants)); }
public void ParticipantsOfRoomChanged_SomeChangesInOtherRooms_ReturnFalse() { // arrange var current = new SynchronizedRooms(ImmutableList <Room> .Empty, "default", ImmutableDictionary <string, string> .Empty); var previous = new SynchronizedRooms(ImmutableList <Room> .Empty, "default", new Dictionary <string, string> { { "p1", "room2" } }); // act var result = SceneUtilities.ParticipantsOfRoomChanged("room1", current, previous); // assert Assert.False(result); }
private async ValueTask <Participant?> VerifyCurrentSpeakerInRoom(Participant?currentSpeaker, string roomId, SynchronizedRooms rooms) { if (currentSpeaker == null) { return(null); } if (CheckParticipantIsInRoom(currentSpeaker.Value, roomId, rooms)) { return(currentSpeaker); } await _repository.RemoveCurrentSpeaker(currentSpeaker.Value.ConferenceId, roomId); return(null); }
public void GetParticipantsOfRoom_SomeParticipants_ReturnParticipants() { // arrange var rooms = new SynchronizedRooms(ImmutableList <Room> .Empty, "d", new Dictionary <string, string> { { "p1", "room1" }, { "p2", "room1" }, { "p3", "room2" }, { "p4", "room4" }, }); // act var result = SceneUtilities.GetParticipantsOfRoom(rooms, "room1"); // assert AssertHelper.AssertScrambledEquals(new[] { "p1", "p2" }, result); }
private static bool CheckParticipantIsInRoom(Participant participant, string roomId, SynchronizedRooms rooms) { return(rooms.Participants.TryGetValue(participant.Id, out var actualRoomId) && actualRoomId == roomId); }
private async ValueTask ElectNewCurrentSpeaker(string conferenceId, string roomId, SynchronizedRooms rooms, TalkingStickMode mode) { if (mode == TalkingStickMode.Queue) { var nextSpeaker = await _repository.Dequeue(conferenceId, roomId); if (nextSpeaker == null) { return; } if (!CheckParticipantIsInRoom(nextSpeaker.Value, roomId, rooms)) { await ElectNewCurrentSpeaker(conferenceId, roomId, rooms, mode); return; } await _repository.SetCurrentSpeakerAndRemoveFromQueue(nextSpeaker.Value, roomId); } }
private IEnumerable <Room> MapOpenedRooms(SynchronizedRooms syncRooms, IEnumerable <string> openedRooms) { return(syncRooms.Rooms.Where(x => openedRooms.Contains(x.RoomId)).ToList()); }
public static IEnumerable <string> GetParticipantsOfRoom(SynchronizedRooms rooms, string roomId) { return(rooms.Participants.Where(x => x.Value == roomId).Select(x => x.Key)); }