public async Task ParticipantJoinedInConference_RemoveParticipantAndReturnOldConferenceId() { const string participantKey = "2AFA88F3-50E3-4356-9529-F47A730B25B0"; const string participantId = "14FAA2C6-8FAC-46D1-B34C-6916F5D213D7"; const string conferenceKeyTemplate = "conference:7fa3aba5bfdb4a648294fe9fb5df40dc:*"; const string currentConferenceId = "50DABA18-7F83-4D0D-8FDD-B2ADE18C5FBC"; const string currentConferenceKey = "conference:7fa3aba5bfdb4a648294fe9fb5df40dc:" + currentConferenceId; const string currentConnectionId = "7996bdfaf063485492974d74e7e3d657"; // arrange await _database.SetAsync(participantKey, currentConferenceId); await _database.HashSetAsync(currentConferenceKey, participantId, currentConnectionId); // act var result = await Execute(participantId, participantKey, conferenceKeyTemplate); // assert var arr = (string[])result; Assert.Equal(arr[0], currentConferenceId); Assert.Equal(arr[1], currentConnectionId); var participantKeyExists = await _database.KeyDeleteAsync(participantKey); Assert.False(participantKeyExists); var participantMappingExists = await _database.HashExistsAsync(currentConferenceKey, participantId); Assert.False(participantMappingExists); }
public async ValueTask SetTemporaryPermission(Participant participant, string key, JValue value) { var redisKey = GetKey(participant.ConferenceId); var lockKey = GetLockKey(participant); await using (await _redisDatabase.AcquireLock(lockKey)) { var currentPermissions = await FetchTemporaryPermissions(participant); var newPermissions = new Dictionary <string, JValue>(currentPermissions) { [key] = value }; await _redisDatabase.HashSetAsync(redisKey, participant.Id, newPermissions); } }
public async Task RoomDoesNotExist_DoNotChangeAndReturnFalse() { const string roomMappingKey = "8D87925C-96DA-4B7A-9442-1938422B87E3"; const string roomListKey = "B9781B02-A5AA-4B10-AE7D-408CC27FC1E6"; const string participantId = "EB13BB6A-6693-4644-8578-8A47E21C2DA2"; const string newRoomId = "3189C8E6-4C85-4B8F-9C50-EEB51E09B338"; const string currentRoomId = "differentRoomId"; // arrange await _database.HashSetAsync(roomListKey, currentRoomId, "something"); await _database.HashSetAsync(roomMappingKey, participantId, currentRoomId); // act var result = await Execute(roomMappingKey, roomListKey, participantId, newRoomId); // assert Assert.False((bool)result); var actualMapping = await _database.HashGetAsync(roomMappingKey, participantId); Assert.Equal(currentRoomId, actualMapping); }
public async Task ParticipantJoinedButDifferentConnectionId_DontRemoveAndReturnFalse() { const string participantKey = "2AFA88F3-50E3-4356-9529-F47A730B25B0"; const string participantId = "14FAA2C6-8FAC-46D1-B34C-6916F5D213D7"; const string conferenceKeyTemplate = "conference:7fa3aba5bfdb4a648294fe9fb5df40dc:*"; const string conferenceId = "50DABA18-7F83-4D0D-8FDD-B2ADE18C5FBC"; const string conferenceKey = "conference:7fa3aba5bfdb4a648294fe9fb5df40dc:" + conferenceId; const string connectionId = "7996bdfaf063485492974d74e7e3d657"; // arrange await _database.SetAsync(participantKey, conferenceId); await _database.HashSetAsync(conferenceKey, participantId, connectionId); // act var result = await Execute(participantId, participantKey, conferenceKeyTemplate, "differentId"); // assert Assert.False((bool)result); var actualConferenceId = await _database.GetAsync(participantKey); Assert.NotNull(actualConferenceId); }
public async ValueTask AddParticipant(Participant participant, ParticipantMetadata data) { var key = GetKey(participant.ConferenceId); await _database.HashSetAsync(key, participant.Id, data); }
public async ValueTask CreateRoom(string conferenceId, Room room) { var key = GetRoomListKey(conferenceId); await _database.HashSetAsync(key, room.RoomId, room); }
public async ValueTask SetConnection(Participant participant, EquipmentConnection connection) { var key = GetKey(participant); await _database.HashSetAsync(key, connection.ConnectionId, connection); }
public async ValueTask SetScene(string conferenceId, string roomId, ActiveScene scene) { var key = GetSceneKey(conferenceId); await _database.HashSetAsync(key, roomId, scene); }
public async ValueTask CreatePoll(string conferenceId, Poll poll) { var pollsKey = GetPollsKey(conferenceId); await _database.HashSetAsync(pollsKey, poll.Id, poll); }
public ValueTask Set(Participant participant, string token) { var key = GetKey(participant.ConferenceId); return(_database.HashSetAsync(key, participant.Id, token)); }