Ejemplo n.º 1
0
        public async Task GetMessageForUser_Success()
        {
            //arrange
            var user = await _dataContext.Users.FirstAsync();

            var recipient = await _dataContext.Users.FirstAsync(x => x.Id != user.Id);

            var messageModel = new Message
            {
                SenderId         = user.Id,
                MessageSent      = DateTime.Now,
                RecipientId      = recipient.Id,
                IsRead           = true,
                Content          = "Hello World",
                DateRead         = DateTime.Now,
                SenderDeleted    = false,
                RecipientDeleted = false
            };

            await _dataContext.Messages.AddAsync(messageModel);

            var messageModel2 = new Message
            {
                SenderId    = recipient.Id,
                MessageSent = DateTime.Now,
                RecipientId = user.Id,
                IsRead      = false,
                Content     = "Hello you!"
            };

            await _dataContext.Messages.AddAsync(messageModel);

            await _dataContext.SaveChangesAsync();

            var messageParams = new MessageParams
            {
                PageNumber       = 1,
                PageSize         = 5,
                UserId           = user.Id,
                MessageContainer = "Outbox"
            };

            //run
            var result = await _datingRepository.GetMessagesForUser(messageParams);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
        }