Esempio n. 1
0
        public async Task GetMessage_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      = false,
                Content     = "Hello World"
            };

            await _dataContext.Messages.AddAsync(messageModel);

            var messageId = await _dataContext.SaveChangesAsync();

            //run
            var result = await _datingRepository.GetMessage(messageId);

            Assert.IsNotNull(result);
            Assert.AreEqual(user, result.Sender);
            Assert.AreEqual(recipient, result.Recipient);
        }