public async void ShouldChangeMailStatusAfterSending() { List <Mail> initialMails = new List <Mail> { new Mail { Sender = "*****@*****.**", Content = "test", Priority = Priority.Important, Status = Status.Pending, Recipients = new List <Recipient> { new Recipient { RecipientMail = "*****@*****.**" } } }, new Mail { Sender = "*****@*****.**", Content = "test", Priority = Priority.Important, Status = Status.Pending, Recipients = new List <Recipient> { new Recipient { RecipientMail = "*****@*****.**" } } } }; int userId = 1; _mailRepositoryMock.Setup(x => x.GetPendingMailsByUserIdAsync(It.IsAny <int>())) .ReturnsAsync(() => initialMails); _mailRepositoryMock.Setup(x => x.GetAllMailsByUserIdAsync(It.IsAny <int>())) .ReturnsAsync(() => initialMails); await _mailSrv.SendMailAsync(userId); var mails = await _mailSrv.GatAllMailsByUserIdAsync(userId); Assert.True(mails.All((x) => x.Status == Status.Sent)); }
public async Task <IActionResult> GatAllMailsAsync(int id) { var mails = await _mailSrv.GatAllMailsByUserIdAsync(id); return(Ok(mails)); }