public async Task <IEnumerable <NotificationAuditForDisplay> > HandleAsync(GetNotificationAudits message) { IEnumerable <Audit> notificationAudits = await repository.GetNotificationAuditsById(message.NotificationId); return(notificationAudits .Select(updateHistoryItem => mapper.Map <NotificationAuditForDisplay>(updateHistoryItem)) .OrderByDescending(x => x.DateAdded) .ToList()); }
public NotificationAuditGetHandlerTests() { context = new TestIwsContext(); var repo = A.Fake <INotificationAuditRepository>(); mapper = A.Fake <IMapper>(); var notificationId = Guid.NewGuid(); notificationAudit = new Audit(Guid.NewGuid(), "UserGuid1", 1, 1, new DateTimeOffset()); notificationAudits = new List <Audit>() { notificationAudit, notificationAudit }; var notificationAuditForDisplay = new NotificationAuditForDisplay("UserName1", "Screen1", "AuditType1", new DateTimeOffset()); A.CallTo(() => repo.GetNotificationAuditsById(notificationId)).Returns(notificationAudits); A.CallTo(() => mapper.Map <NotificationAuditForDisplay>(notificationAudit)).Returns(notificationAuditForDisplay); handler = new GetNotificationAuditHandler(context, mapper, repo); message = new GetNotificationAudits(notificationId); }