public void after_deleted_message_all_connected_user_message_must_have_deleted_state() { var newMessage = DatabaseHelper.CreateValidMessage(DatabaseHelper.UserTest2A); var userMessage1 = DatabaseHelper.CreateValidUserMessage(newMessage, DatabaseHelper.UserTest2A, modeEnum: UserMessageCreationModeEnum.ByHimselfNew); var userMessage2 = DatabaseHelper.CreateValidUserMessage(newMessage, DatabaseHelper.UserTest1); _messageRepository.Create(newMessage); _userMessageRepository.Create(userMessage1); _userMessageRepository.Create(userMessage2); _unitOfWork.Commit(); _messageService.Delete(newMessage.Id); _unitOfWork.Commit(); int amountOfDeleted = _userMessageRepository.FindAll().Count(x => x.Message.Id == newMessage.Id && x.UserMessageState.UserMessageStateEnum == UserMessageStateEnum.Deleted); Assert.AreEqual(2, amountOfDeleted, "All user message must have delete state after deleted message"); }
public UserMessageSearchResult SearchMessages(string s, int page, int amountOnPage) { IQueryable <UserMessage> allFoundQuery = _userMessageRepository.FindAll() .Where(x => x.UserMessageState.UserMessageStateEnum != UserMessageStateEnum.Deleted && x.Message.MessageState.MessageStateEnum == MessageStateEnum.Published && x.UserMessageCreationMode.UserMessageCreationModeEnum == UserMessageCreationModeEnum.ByHimselfNew && (x.Message.Mind.Contains(s) || x.Message.Speech.Contains(s))); int allResults = allFoundQuery.Count(); IQueryable <UserMessage> partResultQuery = allFoundQuery.OrderBy(x => x.CreationDate).Skip(page * amountOnPage).Take(amountOnPage); var userMessageSearchResult = new UserMessageSearchResult { AmountOnPage = amountOnPage, Page = page, AllResults = allResults, UserMessages = partResultQuery.ToList() }; return(userMessageSearchResult); }
public void message_must_appears_in_direct_observers_main_feed_when_observed_user_add_message() { const string mindText = "acb99b89-22f4-4290-b1ae-beae5ff377c0"; var createdMessage = _messageService.CreateMind(mindText, DatabaseHelper.UserTest2A.Id); _unitOfWork.Commit(); _userMessageService.PublishMessage(createdMessage); var numberOfAllUser2AMessages = _userMessageRepository.FindAll().Count(x => x.User.Id == DatabaseHelper.UserTest2A.Id && x.Message.Mind == mindText); var numberOfAllUser2BMessages = _userMessageRepository.FindAll().Count(x => x.User.Id == DatabaseHelper.UserTest2B.Id && x.Message.Mind == mindText); var numberOfAllUser1Messages = _userMessageRepository.FindAll().Count(x => x.User.Id == DatabaseHelper.UserTest1.Id && x.Message.Mind == mindText); Assert.AreEqual(1, numberOfAllUser2AMessages, "Message must appear on usertest2A feed when usertest2A adding a mesage (himself)"); Assert.AreEqual(1, numberOfAllUser2BMessages, "Message must appear on usertest2B feed when usertest2A adding a mesage (observer)"); Assert.AreEqual(1, numberOfAllUser1Messages, "Message must appear on usertest1 feed when usertest2A adding a mesage (observer)"); }
public bool HasRightToUserMessage(Guid userId, Guid userMessageId) { return(_userMessageRepository.FindAll(userId).Any(x => x.Id == userMessageId)); }