public void ShouldGetAmountOfMessages()
        {
            Chat chat = Create.Chat();

            for (int i = 0; i < 10; i++)
            {
                Message message = new Message
                {
                    Text       = "Message" + i,
                    UserFromID = chat.Members.ToArray()[0].UserID,
                    ChatToID   = chat.ID
                };

                messagesRepository.SendMessage(message);
            }

            var messages = messagesRepository.GetAmountOfMessages(chat.ID, 0, 5);

            Assert.AreEqual(5, messages.Count());
        }
Пример #2
0
        public void SholdGetAmount()
        {
            User user1 = Helper.CreateUser(_connectionString, Helper.NewUser());
            User user2 = Helper.CreateUser(_connectionString, Helper.NewUser());

            UsersRepository userRepository = new UsersRepository(_connectionString);
            ChatsRepository chatRepository = new ChatsRepository(_connectionString, userRepository);

            var resultCreate = chatRepository.Create(new[] { user1.Id, user2.Id }, "NewChat");

            Message message1 = new Message
            {
                Text   = "message",
                UserId = user1.Id,
                ChatId = resultCreate.Id,
            };
            Message message2 = new Message
            {
                Text   = "message2",
                UserId = user2.Id,
                ChatId = resultCreate.Id,
            };
            Message message3 = new Message
            {
                Text   = "message3",
                UserId = user1.Id,
                ChatId = resultCreate.Id,
            };
            MessagesRepository messagesRepository = new MessagesRepository(_connectionString, userRepository, chatRepository);

            message1 = messagesRepository.Send(message1.UserId, message1.ChatId, message1.Text, null);
            message2 = messagesRepository.Send(message2.UserId, message2.ChatId, message2.Text, null);
            message3 = messagesRepository.Send(message3.UserId, message3.ChatId, message3.Text, null);
            var result = messagesRepository.GetAmountOfMessages(resultCreate.Id, 1, 1);

            Assert.AreEqual(1, result.Count());
        }
Пример #3
0
 public object GetAmount(Guid chatId, int skip, int amount)
 {
     return(messagesRepository.GetAmountOfMessages(chatId, skip, amount));
 }
 public IEnumerable <Message> GetMessages(Guid chatId, int skip, int amount)
 => _messagesRepository.GetAmountOfMessages(chatId, skip, amount);