Esempio n. 1
0
        public async Task HappyPathShouldCreateTopic()
        {
            var client = new Mock <IAmazonSimpleNotificationService>();

            MockCreateTopic(client, TestCreateTopicResponse());

            var logger          = new Mock <IAlarmLogger>();
            var snsTopicCreator = new SnsTopicCreator(client.Object, logger.Object);

            var topicArn = await snsTopicCreator.EnsureSnsTopic("test1", false);

            Assert.That(topicArn, Is.Not.Null);
            Assert.That(topicArn, Is.EqualTo("testResponse-abc123"));

            client.Verify(c => c.CreateTopicAsync("test1-Alerts", It.IsAny <CancellationToken>()), Times.Once);
        }
Esempio n. 2
0
        public async Task DryRunShouldNotCreateTopic()
        {
            var client = new Mock <IAmazonSimpleNotificationService>();

            MockCreateTopic(client, TestCreateTopicResponse());

            var logger          = new Mock <IAlarmLogger>();
            var snsTopicCreator = new SnsTopicCreator(client.Object, logger.Object);

            var topicArn = await snsTopicCreator.EnsureSnsTopic("test1", true);

            Assert.That(topicArn, Is.Not.Null);

            client.Verify(c => c.CreateTopicAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()),
                          Times.Never);
        }
Esempio n. 3
0
        public async Task WhenTopicExistsShouldNotCreateTopic()
        {
            var client = new Mock <IAmazonSimpleNotificationService>();

            client.Setup(c => c.FindTopicAsync(It.IsAny <string>()))
            .ReturnsAsync(TestFindTopicResponse());

            MockCreateTopic(client, TestCreateTopicResponse());

            var logger          = new Mock <IAlarmLogger>();
            var snsTopicCreator = new SnsTopicCreator(client.Object, logger.Object);

            var topicArn = await snsTopicCreator.EnsureSnsTopic("test1", false);

            Assert.That(topicArn, Is.Not.Null);
            Assert.That(topicArn, Is.EqualTo("existingTopicArn-abc-1234"));

            client.Verify(c => c.CreateTopicAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()),
                          Times.Never);
        }
 public void GivenCreatingATopicWillReturnAnArn(string alertingGroupName, string snsTopicArn)
 {
     SnsTopicCreator.Setup(x => x.EnsureSnsTopic(alertingGroupName, It.IsAny <bool>()))
     .ReturnsAsync(snsTopicArn);
 }
 public void ValidSnsTopic()
 {
     SnsTopicCreator.Setup(x => x.EnsureSnsTopic(It.IsAny <string>(), It.IsAny <bool>()))
     .ReturnsAsync("sns-topic-arn");
 }