public void GetPendingNotificationListTest() { List <vNotification> list = NotificationSenderAgent.GetPendingNotificationList(); foreach (vNotification item in list) { bool checkSMS = true; if (item.IsEmail) { if (item.EmailNotificationStatusID != (int)EntityEnums.NotificationStatusEnum.Pending) { Assert.Fail("EmailNotificationStatusID should be pending for GetPendingNotificationList function"); } else { checkSMS = false; } } if (checkSMS) // if it was not email pending check SMS status { if (item.SMSNotificationStatusID != (int)EntityEnums.NotificationStatusEnum.Pending && item.IsSMS) { Assert.Fail("SMSNotificationStatusID should be pending for GetPendingNotificationList function"); } } } }
public void SendNotificationTest() { Notification notification = CreateNewNotification((short)EntityEnums.NotificationTemplateEnum.TestNotification); notification.IsSMS = true; notification.IsMobilePushMessage = true; INotificationService service = (INotificationService) EntityFactory.GetEntityServiceByName(vNotification.EntityName, ""); service.Insert(notification, new InsertParameters()); vNotification nSaved = (vNotification)service.GetByID(notification.NotificationID, new GetByIDParameters(GetSourceTypeEnum.View)); NotificationSenderAgent.SendNotification(nSaved); // Check that log inserted for all notifications (no error happened anywhere) IAppLogService logService = (IAppLogService) EntityFactory.GetEntityServiceByName(AppLog.EntityName, ""); FilterExpression filter = new FilterExpression(new Filter(AppLog.ColumnNames.ExtraBigInt, nSaved.NotificationID)); FilterExpression f2 = new FilterExpression(); f2.AddFilter(new Filter(AppLog.ColumnNames.AppLogTypeID, (int)EntityEnums.AppLogType.Notify_Email)); f2.AddFilter(new Filter(AppLog.ColumnNames.AppLogTypeID, (int)EntityEnums.AppLogType.Notify_MobilePush)); f2.AddFilter(new Filter(AppLog.ColumnNames.AppLogTypeID, (int)EntityEnums.AppLogType.Notify_SMS)); f2.LogicalOperator = FilterLogicalOperatorEnum.OR; filter.AndMerge(f2); long logCount = logService.GetCount(filter); Assert.AreEqual(2, logCount, "EMAIL, SMS has not saved in logs. So, error in media"); // check that all parameters are valid after save vNotification nSaved2 = (vNotification)service.GetByID(notification.NotificationID, new GetByIDParameters(GetSourceTypeEnum.View)); Assert.IsNull(nSaved2.NotificationErrorMessage); Assert.IsNotNull(nSaved2.EmailSendDate); Assert.IsNotNull(nSaved2.SMSSendDate); }
public static void MyClassInitialize(TestContext testContext) { agent = new NotificationSenderAgent(); }