public void AddChatMessage(Guid chatRoomId, ChatMessageText chatMessageText) { ChatRoom chatRoom = _chatRoomRepository .Get(new ChatRoomSpecification(chatRoomId)) .FirstOrDefault(); if (chatRoom != default(ChatRoom)) { chatRoom.AddMessage(chatMessageText); _chatRoomRepository.Update(chatRoom); } _logger.LogInformation($"Chat room with id {chatRoomId.ToString()} not found.", null); }
public void AddChatMessageBelowBoundaries() { this.chatRoom.ClearMessages(); chatRoom.AddMessage(new ChatMessageText(Guid.NewGuid(), "Hello!")); (bool result, string message) = chatRoom.AddMessage(new ChatMessageText(Guid.NewGuid(), "Hello!")); Assert.AreEqual(true, result); Assert.AreEqual(string.Empty, message); }
void Handle_SendMessage(object sender, System.EventArgs e) { if (!(BindingContext is MainPageViewModel vm)) { return; } try { var m = currentRoom?.AddMessage(vm.Username, vm.NewMessage); vm.NewMessage = ""; vm.Error = null; newMessage.Focus(); } catch (Exception ex) { vm.Error = ex; } }