private EmailNotificationItemEntity ConvertToEmailNotificationItemEntity(EmailNotificationItemTableEntity emailNotificationItemTableEntity) { EmailNotificationItemEntity emailNotificationItemEntity = new EmailNotificationItemEntity(); NotificationPriority notificationPriority = Enum.TryParse <NotificationPriority>(emailNotificationItemTableEntity.Priority, out notificationPriority) ? notificationPriority : NotificationPriority.Low; NotificationItemStatus notificationItemStatus = Enum.TryParse <NotificationItemStatus>(emailNotificationItemTableEntity.Status, out notificationItemStatus) ? notificationItemStatus : NotificationItemStatus.Queued; emailNotificationItemEntity.Priority = notificationPriority; emailNotificationItemEntity.Status = notificationItemStatus; emailNotificationItemEntity.PartitionKey = emailNotificationItemTableEntity.Application; emailNotificationItemEntity.RowKey = emailNotificationItemTableEntity.NotificationId; emailNotificationItemEntity.Application = emailNotificationItemTableEntity.Application; emailNotificationItemEntity.BCC = emailNotificationItemTableEntity.BCC; emailNotificationItemEntity.CC = emailNotificationItemTableEntity.CC; emailNotificationItemEntity.EmailAccountUsed = emailNotificationItemTableEntity.EmailAccountUsed; emailNotificationItemEntity.ErrorMessage = emailNotificationItemTableEntity.ErrorMessage; emailNotificationItemEntity.Footer = emailNotificationItemTableEntity.Footer; emailNotificationItemEntity.From = emailNotificationItemTableEntity.From; emailNotificationItemEntity.Header = emailNotificationItemTableEntity.Header; emailNotificationItemEntity.NotificationId = emailNotificationItemTableEntity.NotificationId; emailNotificationItemEntity.ReplyTo = emailNotificationItemTableEntity.ReplyTo; emailNotificationItemEntity.Sensitivity = emailNotificationItemTableEntity.Sensitivity; emailNotificationItemEntity.Subject = emailNotificationItemTableEntity.Subject; emailNotificationItemEntity.TemplateId = emailNotificationItemTableEntity.TemplateId; emailNotificationItemEntity.Timestamp = emailNotificationItemTableEntity.Timestamp; emailNotificationItemEntity.To = emailNotificationItemTableEntity.To; emailNotificationItemEntity.TrackingId = emailNotificationItemTableEntity.TrackingId; emailNotificationItemEntity.TryCount = emailNotificationItemTableEntity.TryCount; emailNotificationItemEntity.ETag = emailNotificationItemTableEntity.ETag; emailNotificationItemEntity.SendOnUtcDate = emailNotificationItemTableEntity.SendOnUtcDate; return(emailNotificationItemEntity); }
private EmailNotificationItemTableEntity ConvertToEmailNotificationItemTableEntity(EmailNotificationItemEntity emailNotificationItemEntity) { EmailNotificationItemTableEntity emailNotificationItemTableEntity = new EmailNotificationItemTableEntity(); emailNotificationItemTableEntity.PartitionKey = emailNotificationItemEntity.Application; emailNotificationItemTableEntity.RowKey = emailNotificationItemEntity.NotificationId; emailNotificationItemTableEntity.Application = emailNotificationItemEntity.Application; emailNotificationItemTableEntity.BCC = emailNotificationItemEntity.BCC; emailNotificationItemTableEntity.CC = emailNotificationItemEntity.CC; emailNotificationItemTableEntity.EmailAccountUsed = emailNotificationItemEntity.EmailAccountUsed; emailNotificationItemTableEntity.ErrorMessage = emailNotificationItemEntity.ErrorMessage; emailNotificationItemTableEntity.Footer = emailNotificationItemEntity.Footer; emailNotificationItemTableEntity.From = emailNotificationItemEntity.From; emailNotificationItemTableEntity.Header = emailNotificationItemEntity.Header; emailNotificationItemTableEntity.NotificationId = emailNotificationItemEntity.NotificationId; emailNotificationItemTableEntity.Priority = emailNotificationItemEntity.Priority.ToString(); emailNotificationItemTableEntity.ReplyTo = emailNotificationItemEntity.ReplyTo; emailNotificationItemTableEntity.Sensitivity = emailNotificationItemEntity.Sensitivity; emailNotificationItemTableEntity.Status = emailNotificationItemEntity.Status.ToString(); emailNotificationItemTableEntity.Subject = emailNotificationItemEntity.Subject; emailNotificationItemTableEntity.TemplateId = emailNotificationItemEntity.TemplateId; emailNotificationItemTableEntity.Timestamp = emailNotificationItemEntity.Timestamp; emailNotificationItemTableEntity.To = emailNotificationItemEntity.To; emailNotificationItemTableEntity.TrackingId = emailNotificationItemEntity.TrackingId; emailNotificationItemTableEntity.TryCount = emailNotificationItemEntity.TryCount; emailNotificationItemTableEntity.ETag = emailNotificationItemEntity.ETag; emailNotificationItemTableEntity.SendOnUtcDate = emailNotificationItemEntity.SendOnUtcDate; return(emailNotificationItemTableEntity); }
public async Task GetEmailNotificationItemEntitiesBetweenDatesTests() { var statusList = new List <NotificationItemStatus>() { NotificationItemStatus.Failed }; var emailNotificationItemEntity = new EmailNotificationItemTableEntity() { Application = this.applicationName, NotificationId = Guid.NewGuid().ToString(), }; var notificationList = new List <EmailNotificationItemTableEntity>() { emailNotificationItemEntity }; var emailHistoryTable = new Mock <CloudTable>(new Uri("http://unittests.localhost.com/FakeTable"), (TableClientConfiguration)null); _ = this.cloudStorageClient.Setup(x => x.GetCloudTable("EmailHistory")).Returns(emailHistoryTable.Object); _ = emailHistoryTable.Setup(x => x.ExecuteQuery(It.IsAny <TableQuery <EmailNotificationItemTableEntity> >(), It.IsAny <TableRequestOptions>(), It.IsAny <OperationContext>())).Returns(notificationList); IOptions <StorageAccountSetting> options = Options.Create <StorageAccountSetting>(new StorageAccountSetting { BlobContainerName = "Test", ConnectionString = "Test Con", MailTemplateTableName = "MailTemplate", EmailHistoryTableName = "EmailHistory", MeetingHistoryTableName = "MeetingHistory", NotificationQueueName = "test-queue" }); var classUnderTest = new TableStorageEmailRepository(options, this.cloudStorageClient.Object, this.logger.Object, this.mailAttachmentRepository.Object); // dateRange is Null. _ = Assert.ThrowsAsync <ArgumentNullException>(async() => await classUnderTest.GetPendingOrFailedEmailNotificationsByDateRange(null, this.applicationName, statusList)); // applicationname is Null var result = await classUnderTest.GetPendingOrFailedEmailNotificationsByDateRange(this.dateRange, null, statusList); Assert.IsNotNull(result); Assert.AreEqual(result.FirstOrDefault().NotificationId, emailNotificationItemEntity.NotificationId); // NotificationStatusList is null result = await classUnderTest.GetPendingOrFailedEmailNotificationsByDateRange(this.dateRange, this.applicationName, null); Assert.IsNotNull(result); Assert.AreEqual(result.FirstOrDefault().NotificationId, emailNotificationItemEntity.NotificationId); // Fetched records are null notificationList = null; _ = emailHistoryTable.Setup(x => x.ExecuteQuery(It.IsAny <TableQuery <EmailNotificationItemTableEntity> >(), It.IsAny <TableRequestOptions>(), It.IsAny <OperationContext>())).Returns(notificationList); classUnderTest = new TableStorageEmailRepository(options, this.cloudStorageClient.Object, this.logger.Object, this.mailAttachmentRepository.Object); result = await classUnderTest.GetPendingOrFailedEmailNotificationsByDateRange(this.dateRange, this.applicationName, null); Assert.IsNull(result); }