public void GetWebNotificationsReport_NotificationsInDb_FilledReport() { mockUnitOfWork.Setup(m => m.Notifications.Get(It.IsAny <Expression <Func <Notification, bool> > >() , It.IsAny <Func <IQueryable <Notification>, IOrderedQueryable <Notification> > >(), It.IsAny <string>())) .Returns(new List <Notification> { new Notification { Time = DateTime.Now, Type = NotificationType.Web }, new Notification { Time = DateTime.Now, Type = NotificationType.Web }, new Notification { Time = DateTime.Now, Type = NotificationType.Web }, new Notification { Time = DateTime.Now, Type = NotificationType.Web }, new Notification { Time = DateTime.MinValue, Type = NotificationType.Web }, new Notification { Time = DateTime.Now, Type = NotificationType.Web }, new Notification { Time = DateTime.Now, Type = NotificationType.Web }, new Notification { Time = DateTime.MaxValue, Type = NotificationType.Web }, }); mockMapper.Setup(m => m.Map <IEnumerable <Notification> , IEnumerable <WebNotificationDTO> >(It.IsAny <IEnumerable <Notification> >())) .Returns(new List <WebNotificationDTO> { new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO() }); var result = handler.GetWebNotificationsReport("Hello"); Assert.That(result.Notifications.Any()); }
public void GetWebNotificationsReport_NotificationsInDb_FilledReport() { mockUnitOfWork.Setup(m => m.CampaignNotifications.Get(It.IsAny <Expression <Func <CampaignNotification, bool> > >() , It.IsAny <Func <IQueryable <CampaignNotification>, IOrderedQueryable <CampaignNotification> > >(), It.IsAny <string>())) .Returns(new List <CampaignNotification> { new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, new CampaignNotification { Type = NotificationType.Web , Campaign = new Company { SendingTime = DateTime.Now } }, }); mockMapper.Setup(m => m.Map <IEnumerable <CampaignNotification> , IEnumerable <WebNotificationDTO> >(It.IsAny <IEnumerable <CampaignNotification> >())) .Returns(new List <WebNotificationDTO> { new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO() }); mockBaseHandler.Setup(m => m.GetWebNotificationsReport(It.IsAny <string>())) .Returns(new NotificationReportDTO()); mockUnitOfWork.Setup(m => m.Companies.Get(It.IsAny <Expression <Func <Company, bool> > >() , It.IsAny <Func <IQueryable <Company>, IOrderedQueryable <Company> > >(), It.IsAny <string>())) .Returns(new List <Company>()); mockUnitOfWork.Setup(m => m.ApplicationUsers.Get(It.IsAny <Expression <Func <ApplicationUser, bool> > >() , It.IsAny <Func <IQueryable <ApplicationUser>, IOrderedQueryable <ApplicationUser> > >(), It.IsAny <string>())) .Returns(new List <ApplicationUser> { new ApplicationUser { ApplicationGroupId = 10 } }); var result = handler.GetWebNotificationsReport("Hello"); Assert.That(result.Notifications.Any()); }
public void GetWebNotificationsReport_NotificationsInDb_FilledReport() { mockUnitOfWork.Setup(m => m.EmailCampaignNotifications.Get(It.IsAny <Expression <Func <EmailCampaignNotification, bool> > >() , It.IsAny <Func <IQueryable <EmailCampaignNotification>, IOrderedQueryable <EmailCampaignNotification> > >(), It.IsAny <string>())) .Returns(new List <EmailCampaignNotification> { new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, new EmailCampaignNotification { Type = NotificationType.Web , EmailCampaign = new EmailCampaign { SendingTime = DateTime.Now } }, }); mockMapper.Setup(m => m.Map <IEnumerable <EmailCampaignNotification> , IEnumerable <WebNotificationDTO> >(It.IsAny <IEnumerable <EmailCampaignNotification> >())) .Returns(new List <WebNotificationDTO> { new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO(), new WebNotificationDTO() }); mockBaseHandler.Setup(m => m.GetWebNotificationsReport(It.IsAny <string>())) .Returns(new NotificationReportDTO()); mockUnitOfWork.Setup(m => m.EmailCampaigns.Get(It.IsAny <Expression <Func <EmailCampaign, bool> > >() , It.IsAny <Func <IQueryable <EmailCampaign>, IOrderedQueryable <EmailCampaign> > >(), It.IsAny <string>())) .Returns(new List <EmailCampaign>()); var result = handler.GetWebNotificationsReport("Hello"); Assert.That(result.Notifications.Any()); }
/// <summary> /// Generate web notifications report class with latest notifications and statistics /// </summary> /// <param name="userId">Application User Id</param> public NotificationReportDTO GetWebNotificationsReport(string userId) { var result = handler.GetWebNotificationsReport(userId); return(result); }