public async Task DownloadMeetingTests() { this.EncryptionService = new Mock <IEncryptionService>(); var notificationId = Guid.NewGuid().ToString(); var notifications = new List <MeetingNotificationItemEntity> { new MeetingNotificationItemEntity { NotificationId = notificationId } }; var blobEmailData = new BlobEmailData { NotificationId = notificationId, Body = "Test Body", Attachments = new List <NotificationAttachmentEntity> { new NotificationAttachmentEntity { FileBase64 = "VEhpcyBpcyBhIHRlc3QgYXR0YWNobWVudCBmaWxlLg==", FileName = "Test.txt", IsInline = true } }, }; _ = this.MockedCloudStorageClient.Setup(x => x.DownloadBlobAsync($"TestApp/{ApplicationConstants.MeetingNotificationsFolderName}/{notificationId}")).ReturnsAsync("Test Encrypted String"); _ = this.EncryptionService.Setup(x => x.Decrypt(It.Is <string>(x => x == "Test Encrypted String"))).Returns(JsonConvert.SerializeObject(blobEmailData)); var repo = new MailAttachmentRepository(this.Logger, this.MockedCloudStorageClient.Object, this.EncryptionService.Object); var updatednotifications = await repo.DownloadMeetingInvite(notifications, "TestApp").ConfigureAwait(false); Assert.IsTrue(updatednotifications.Count == 1); Assert.IsTrue(updatednotifications.First().Body.Equals("Test Body")); Assert.IsTrue(updatednotifications.First().Attachments.Any(x => x.FileBase64.Equals("VEhpcyBpcyBhIHRlc3QgYXR0YWNobWVudCBmaWxlLg=="))); Assert.IsTrue(updatednotifications.First().Attachments.Any(x => x.FileName.Equals("Test.txt"))); Assert.IsTrue(updatednotifications.First().Attachments.Any(x => x.IsInline)); this.MockedCloudStorageClient.Verify(x => x.DownloadBlobAsync($"TestApp/{ApplicationConstants.MeetingNotificationsFolderName}/{notificationId}"), Times.Once); this.EncryptionService.Verify(x => x.Decrypt(It.Is <string>(x => x == "Test Encrypted String")), Times.Once); }
public async Task UploadMeetingInviteTests() { this.EncryptionService = new Mock <IEncryptionService>(); var notificationId = Guid.NewGuid().ToString(); var notifications = new List <MeetingNotificationItemEntity> { new MeetingNotificationItemEntity { NotificationId = notificationId } }; _ = this.MockedCloudStorageClient.Setup(x => x.UploadBlobAsync($"TestApp/{ApplicationConstants.MeetingNotificationsFolderName}/{notificationId}", "TestString")).ReturnsAsync($"TestApp/{ApplicationConstants.EmailNotificationsFolderName}/{notificationId}"); _ = this.EncryptionService.Setup(x => x.Encrypt(It.IsAny <string>())).Returns("TestString"); var repo = new MailAttachmentRepository(this.Logger, this.MockedCloudStorageClient.Object, this.EncryptionService.Object); var updatednotifications = await repo.UploadMeetingInvite(notifications, "TestApp").ConfigureAwait(false); Assert.IsTrue(updatednotifications.Count == 1); this.MockedCloudStorageClient.Verify(x => x.UploadBlobAsync($"TestApp/{ApplicationConstants.MeetingNotificationsFolderName}/{notificationId}", "TestString"), Times.Once); this.EncryptionService.Verify(x => x.Encrypt(It.IsAny <string>()), Times.Once); }