public async Task ShouldSetLastReadMessage() { // Arrange var request = new SetLastReadMessageRequest("864EB62D-D833-47FA-8A88-DDBFE76AE6A7", new Guid("A455F139-09E6-4EF5-B55A-D4C94D05DFDE"), new Guid("01ADF1C2-0B38-4E4F-9E36-0C0BC7908062")); var member = new Member { Id = new Guid("A1538EB3-4E4C-4E39-BDCB-F617003E4BBF") }; _memberRepositoryMock.Setup(x => x.GetMemberBySaasUserIdAsync(It.Is <string>(saasUserId => saasUserId.Equals(request.SaasUserId)))) .ReturnsAsync(member) .Verifiable(); _channelMemberRepositoryMock.Setup(x => x.SetLastReadMessageAsync( It.Is <Guid>(memberId => memberId.Equals(member.Id)), It.Is <Guid>(channelId => channelId.Equals(request.ChannelId)), It.Is <Guid>(messageId => messageId.Equals(request.MessageId)))) .Returns(Task.CompletedTask) .Verifiable(); // Act await _messageService.SetLastReadMessageAsync(request); // Assert VerifyMocks(); }
public async Task SetLastReadMessageAsync(SetLastReadMessageRequest request) { var member = await UnitOfWork.MemberRepository.GetMemberBySaasUserIdAsync(request.SaasUserId); if (member == null) { throw new NetKitChatNotFoundException($"Unable to set last read message. Member {nameof(request.SaasUserId)}:{request.SaasUserId} is not found."); } await UnitOfWork.ChannelMemberRepository.SetLastReadMessageAsync(member.Id, request.ChannelId, request.MessageId); }
public async Task MarkMessageAsReadAsync(string channelId, string messageId) { var dto = new SetLastReadMessageRequest { ChannelId = new Guid(channelId), MessageId = new Guid(messageId) }; var request = new PostMarkAsReadRequest(_chatConfig.ApiUrl, _jsonSerializer, dto); await _httpClient.TrySendAsync(request, _logger).ConfigureAwait(false); }
public async Task SetLastReadMessageAsync(SetLastReadMessageRequest request) { var member = await _memberService.GetMemberBySaasUserIdAsync(request.SaasUserId); var message = await _messageService.GetMessageByIdAsync(request.MessageId); if (message.Sender.Id != member.Id) { await _messageService.SetLastReadMessageAsync(request); var members = new List <Guid> { member.Id, message.Sender.Id }; await _messageNotificationService.OnChangeLastReadMessage(members, message); } }
public static async Task SetLastReadMessageAsync(SignalRClient signalRClient, Guid channelId, Guid messageId) { // Set last read message test var setLastReadMessageRequest = new SetLastReadMessageRequest { ChannelId = channelId, MessageId = messageId, RequestId = Guid.NewGuid().ToString() }; Console.WriteLine("Trying to mark message as read."); await signalRClient.MarkAsReadMessageAsync(setLastReadMessageRequest); Console.WriteLine("Message was marked."); Console.WriteLine(); }
public void ShouldThrowIfMemberDoesNotExist() { // Arrange _memberRepositoryMock.Setup(x => x.GetMemberBySaasUserIdAsync(It.IsAny <string>())) .ReturnsAsync((Member)null) .Verifiable(); var request = new SetLastReadMessageRequest("864EB62D-D833-47FA-8A88-DDBFE76AE6A7", new Guid("A455F139-09E6-4EF5-B55A-D4C94D05DFDE"), new Guid("01ADF1C2-0B38-4E4F-9E36-0C0BC7908062")); // Act Func <Task> act = async() => { await _messageService.SetLastReadMessageAsync(request); }; // Assert act.Should().Throw <NetKitChatNotFoundException>() .And.Message.Should().Be($"Unable to set last read message. Member {nameof(request.SaasUserId)}:{request.SaasUserId} is not found."); VerifyMocks(); }
public Task MarkAsReadMessageAsync(SetLastReadMessageRequest request) { return(SendAndHandleExceptionsAsync(ServerMethods.MarkAsReadMessageAsync, request)); }
public async Task MarkAsReadMessageAsync(SetLastReadMessageRequest request) { await _connection.InvokeAsync(MarkAsReadMessageCommandName, request); }