public async Task OneTimeTearDown() { // Once all tests have completed, delete all queues that were created. // Use the QueueNamePrefix to determine which queues to delete. var transport = new TransportExtensions <SqsTransport>(new SettingsHolder()); transport = transport.ConfigureSqsTransport(SqsQueueNamePrefix); var transportConfiguration = new TransportConfiguration(transport.GetSettings()); using (var sqsClient = SqsTransportExtensions.CreateSQSClient()) { var listQueuesResult = await sqsClient.ListQueuesAsync(transportConfiguration.QueueNamePrefix).ConfigureAwait(false); foreach (var queueUrl in listQueuesResult.QueueUrls) { try { await sqsClient.DeleteQueueAsync(queueUrl).ConfigureAwait(false); } catch (Exception ex) { Console.WriteLine($"Exception when deleting queue: {ex}"); } } } }
public async Task OneTimeTearDown() { var accessKeyId = EnvironmentHelper.GetEnvironmentVariable("CLEANUP_AWS_ACCESS_KEY_ID"); var secretAccessKey = EnvironmentHelper.GetEnvironmentVariable("CLEANUP_AWS_SECRET_ACCESS_KEY"); using (var sqsClient = string.IsNullOrEmpty(accessKeyId) ? SqsTransportExtensions.CreateSQSClient() : new AmazonSQSClient(accessKeyId, secretAccessKey)) using (var snsClient = string.IsNullOrEmpty(accessKeyId) ? SqsTransportExtensions.CreateSnsClient() : new AmazonSimpleNotificationServiceClient(accessKeyId, secretAccessKey)) using (var s3Client = string.IsNullOrEmpty(accessKeyId) ? SqsTransportExtensions.CreateS3Client() : new AmazonS3Client(accessKeyId, secretAccessKey)) { await Cleanup.DeleteAllResourcesWithPrefix(sqsClient, snsClient, s3Client, NamePrefix).ConfigureAwait(false); } }