Example #1
0
        public async Task GetMeetingNotificationItemEntitiesTests()
        {
            IEnumerable <MeetingNotificationItemTableEntity> entities = new List <MeetingNotificationItemTableEntity> {
                new MeetingNotificationItemTableEntity {
                    NotificationId = "notificationId1"
                }, new MeetingNotificationItemTableEntity {
                    NotificationId = "notificationId2"
                }
            };
            IList <MeetingNotificationItemEntity> itemEntities = new List <MeetingNotificationItemEntity> {
                new MeetingNotificationItemEntity {
                    NotificationId = "notificationId1"
                }, new MeetingNotificationItemEntity {
                    NotificationId = "notificationId1"
                }
            };

            this.mailAttachmentRepository.Setup(x => x.DownloadMeetingInvite(It.IsAny <IList <MeetingNotificationItemEntity> >(), It.IsAny <string>())).Returns(Task.FromResult(itemEntities));
            var meetingHistoryTable = new Mock <CloudTable>(new Uri("http://unittests.localhost.com/FakeTable"), (TableClientConfiguration)null);

            _ = this.cloudStorageClient.Setup(x => x.GetCloudTable("MeetingHistory")).Returns(meetingHistoryTable.Object);
            _ = meetingHistoryTable.Setup(x => x.ExecuteQuery(It.IsAny <TableQuery <MeetingNotificationItemTableEntity> >(), It.IsAny <TableRequestOptions>(), It.IsAny <OperationContext>())).Returns(entities);
            IOptions <StorageAccountSetting> options = Options.Create <StorageAccountSetting>(new StorageAccountSetting {
                BlobContainerName = "Test", ConnectionString = "Test Con", MailTemplateTableName = "MailTemplate", EmailHistoryTableName = "EmailHistory", MeetingHistoryTableName = "MeetingHistory", NotificationQueueName = "test-queue"
            });
            var repo  = new TableStorageEmailRepository(options, this.cloudStorageClient.Object, this.logger.Object, this.mailAttachmentRepository.Object);
            var items = await repo.GetMeetingNotificationItemEntities(new List <string> {
                "notificationId1", "notificationId2"
            }, this.applicationName);

            Assert.IsTrue(items.Count == 2);
        }
Example #2
0
        public async Task GetMeetingNotificationItemEntitiesTests()
        {
            IEnumerable <MeetingNotificationItemTableEntity> entities = new List <MeetingNotificationItemTableEntity> {
                new MeetingNotificationItemTableEntity {
                    NotificationId = "notificationId1"
                }, new MeetingNotificationItemTableEntity {
                    NotificationId = "notificationId2"
                }
            };
            IList <MeetingNotificationItemEntity> itemEntities = new List <MeetingNotificationItemEntity> {
                new MeetingNotificationItemEntity {
                    NotificationId = "notificationId1"
                }, new MeetingNotificationItemEntity {
                    NotificationId = "notificationId1"
                }
            };

            _ = this.mailAttachmentRepository.Setup(x => x.DownloadMeetingInvite(It.IsAny <IList <MeetingNotificationItemEntity> >(), It.IsAny <string>())).Returns(Task.FromResult(itemEntities));
            _ = this.meetingHistoryTable.Setup(x => x.ExecuteQuery(It.IsAny <TableQuery <MeetingNotificationItemTableEntity> >(), null, null)).Returns(entities);
            IOptions <StorageAccountSetting> options = Options.Create <StorageAccountSetting>(new StorageAccountSetting {
                BlobContainerName = "Test", ConnectionString = "Test Con", MailTemplateTableName = "MailTemplate"
            });
            var repo  = new TableStorageEmailRepository(options, this.cloudStorageClient.Object, this.logger.Object, this.mailAttachmentRepository.Object);
            var items = await repo.GetMeetingNotificationItemEntities(new List <string> {
                "notificationId1", "notificationId2"
            }, this.applicationName);

            Assert.IsTrue(items.Count == 2);
        }
Example #3
0
        public async Task GetMeetingNotificationItemEntitiesBetweenDatesTests()
        {
            var statusList = new List <NotificationItemStatus>()
            {
                NotificationItemStatus.Failed
            };
            var meetingNotificationItemEntity = new MeetingNotificationItemTableEntity()
            {
                Application    = this.applicationName,
                NotificationId = Guid.NewGuid().ToString(),
            };
            var notificationList = new List <MeetingNotificationItemTableEntity>()
            {
                meetingNotificationItemEntity
            };
            var meetingHistoryTable = new Mock <CloudTable>(new Uri("http://unittests.localhost.com/FakeTable"), (TableClientConfiguration)null);

            _ = this.cloudStorageClient.Setup(x => x.GetCloudTable("MeetingHistory")).Returns(meetingHistoryTable.Object);
            _ = meetingHistoryTable.Setup(x => x.ExecuteQuery(It.IsAny <TableQuery <MeetingNotificationItemTableEntity> >(), 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.GetPendingOrFailedMeetingNotificationsByDateRange(null, this.applicationName, statusList));

            // applicationname is Null
            var result = await classUnderTest.GetPendingOrFailedMeetingNotificationsByDateRange(this.dateRange, null, statusList);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.FirstOrDefault().NotificationId, meetingNotificationItemEntity.NotificationId);

            // NotificationStatusList is null
            result = await classUnderTest.GetPendingOrFailedMeetingNotificationsByDateRange(this.dateRange, this.applicationName, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.FirstOrDefault().NotificationId, meetingNotificationItemEntity.NotificationId);

            // Fetched records are null
            notificationList = null;
            _ = meetingHistoryTable.Setup(x => x.ExecuteQuery(It.IsAny <TableQuery <MeetingNotificationItemTableEntity> >(), It.IsAny <TableRequestOptions>(), It.IsAny <OperationContext>())).Returns(notificationList);
            classUnderTest = new TableStorageEmailRepository(options, this.cloudStorageClient.Object, this.logger.Object, this.mailAttachmentRepository.Object);
            result         = await classUnderTest.GetPendingOrFailedMeetingNotificationsByDateRange(this.dateRange, this.applicationName, null);

            Assert.IsNull(result);
        }
Example #4
0
        public async Task CreateMeetingNotificationItemEntitiesTests()
        {
            IList <MeetingNotificationItemEntity> entities = new List <MeetingNotificationItemEntity> {
                new MeetingNotificationItemEntity {
                    NotificationId = "notificationId1", Application = "Application", RowKey = "notificationId1"
                }, new MeetingNotificationItemEntity {
                    NotificationId = "notificationId2", Application = "Application", RowKey = "notificationId2"
                }
            };

            _ = this.mailAttachmentRepository.Setup(e => e.UploadMeetingInvite(It.IsAny <IList <MeetingNotificationItemEntity> >(), It.IsAny <string>())).Returns(Task.FromResult(entities));
            this.meetingHistoryTable.Setup(x => x.ExecuteBatchAsync(It.IsAny <TableBatchOperation>(), null, null)).Verifiable();
            IOptions <StorageAccountSetting> options = Options.Create <StorageAccountSetting>(new StorageAccountSetting {
                BlobContainerName = "Test", ConnectionString = "Test Con", MailTemplateTableName = "MailTemplate", EmailHistoryTableName = "EmailHistory", MeetingHistoryTableName = "MeetingHistory", NotificationQueueName = "test-queue"
            });
            var repo = new TableStorageEmailRepository(options, this.cloudStorageClient.Object, this.logger.Object, this.mailAttachmentRepository.Object);
            await repo.CreateMeetingNotificationItemEntities(entities, this.applicationName);

            this.meetingHistoryTable.Verify(x => x.ExecuteBatchAsync(It.Is <TableBatchOperation>(x => x.Any(y => y.OperationType == TableOperationType.Insert))), Times.Once);
        }
Example #5
0
        public async Task UpdateMeetingNotificationItemEntitiesTests()
        {
            this.meetingHistoryTable = new Mock <CloudTable>(new Uri("http://unittests.localhost.com/FakeTable"), (TableClientConfiguration)null);
            _ = this.cloudStorageClient.Setup(x => x.GetCloudTable("MeetingHistory")).Returns(this.meetingHistoryTable.Object);
            List <MeetingNotificationItemEntity> entities = new List <MeetingNotificationItemEntity> {
                new MeetingNotificationItemEntity {
                    NotificationId = "notificationId1", Application = "Application", RowKey = "notificationId1", ETag = "*"
                }, new MeetingNotificationItemEntity {
                    NotificationId = "notificationId2", Application = "Application", RowKey = "notificationId2", ETag = "*"
                }
            };

            this.meetingHistoryTable.Setup(x => x.ExecuteBatchAsync(It.IsAny <TableBatchOperation>(), null, null)).Verifiable();
            IOptions <StorageAccountSetting> options = Options.Create <StorageAccountSetting>(new StorageAccountSetting {
                BlobContainerName = "Test", ConnectionString = "Test Con", MailTemplateTableName = "MailTemplate", EmailHistoryTableName = "EmailHistory", MeetingHistoryTableName = "MeetingHistory", NotificationQueueName = "test-queue"
            });
            var repo = new TableStorageEmailRepository(options, this.cloudStorageClient.Object, this.logger.Object, this.mailAttachmentRepository.Object);
            await repo.UpdateMeetingNotificationItemEntities(entities);

            this.meetingHistoryTable.Verify(x => x.ExecuteBatchAsync(It.Is <TableBatchOperation>(x => x.Any(y => y.OperationType == TableOperationType.Merge))), Times.Once);
        }