/// <summary> /// Creates the required Sns topic in the configured Sns instance. /// Also creates an <see cref="SnsEventVerifier"/> for the topic. /// </summary> /// <typeparam name="T">The type used for the event payload</typeparam> /// <param name="topicName">The topic name required</param> /// <param name="topicArnEnvVarName">The name of the environment variable against which the created topic arn will be set.</param> /// <param name="snsAttrs">(Optional) List of additional attributes to use in the topic creation.</param> /// <returns>Task</returns> /// <exception cref="System.ArgumentNullException">If the topicName or topicArnEnvVarName are not provided</exception> public void CreateSnsTopic <T>(string topicName, string topicArnEnvVarName, Dictionary <string, string> snsAttrs = null) where T : class { if (string.IsNullOrEmpty(topicName)) { throw new ArgumentNullException(nameof(topicName)); } if (string.IsNullOrEmpty(topicArnEnvVarName)) { throw new ArgumentNullException(nameof(topicArnEnvVarName)); } snsAttrs = snsAttrs ?? new Dictionary <string, string>(); snsAttrs.Add("fifo_topic", "true"); snsAttrs.Add("content_based_deduplication", "true"); var response = SimpleNotificationService.CreateTopicAsync(new CreateTopicRequest { Name = topicName, Attributes = snsAttrs }).Result; Environment.SetEnvironmentVariable(topicArnEnvVarName, response.TopicArn); _snsVerifers[typeof(T).Name] = (new SnsEventVerifier(AmazonSQS, SimpleNotificationService, response.TopicArn)); }
private void CreateSnsTopic() { var snsAttrs = new Dictionary <string, string>(); snsAttrs.Add("fifo_topic", "true"); snsAttrs.Add("content_based_deduplication", "true"); var response = SimpleNotificationService.CreateTopicAsync(new CreateTopicRequest { Name = "repairs", Attributes = snsAttrs }).Result; var logger = TestContext.Out; logger.WriteLine($"Topic ARN: {response.TopicArn}"); Environment.SetEnvironmentVariable("REPAIRS_SNS_ARN", response.TopicArn); }