public void TestGetMessages()
        {
            var guid          = MessageMockings.GetGuid(0);
            var messagesCount = (DbContext.Database.Connection as SqlConnection).QuerySingle <int>("SELECT COUNT(*) FROM Messages WHERE Messages.Chat_Id = @ChatId", new { ChatId = guid });
            var messages      = MessageService.GetMessages(MessageMockings.GetGuid(0)).GetAwaiter().GetResult();

            Assert.AreEqual(messagesCount, messages.Count);
        }
        public void TestGetMessagesPart()
        {
            var guid          = MessageMockings.GetGuid(0);
            var messagesCount = (DbContext.Database.Connection as SqlConnection).QuerySingle <int>("SELECT COUNT(*) FROM Messages WHERE Messages.Chat_Id = @ChatId", new { ChatId = guid });
            var messages      = new List <Message>();

            while (true)
            {
                var newMessages = MessageService
                                  .GetMessages(MessageMockings.GetGuid(0),
                                               messages.Count == 0 ? DateTimeOffset.Now : messages.Last().SentAt, 5)
                                  .GetAwaiter().GetResult();
                if (newMessages.Count == 0)
                {
                    break;
                }
                messages.AddRange(newMessages);
                Assert.AreEqual(messages.Min(message => message.SentAt), messages.Last().SentAt);
            }
            Assert.AreEqual(messagesCount, messages.Count);
        }
 public static void MessageClassInitialize(TestContext testContext)
 {
     MessageMockings.Initalize();
 }
        public void TestGetNewMessages()
        {
            var messages = MessageService.GetNewMessages(MessageMockings.GetGuid(0), DateTimeOffset.MinValue, 20).GetAwaiter().GetResult();

            Assert.AreEqual(20, messages.Count);
        }