public void Preserves_FifoQueue(string destination, string expected) { var configuration = new TransportConfiguration(new SettingsHolder()); var cache = new QueueCache(null, configuration); var result = cache.GetPhysicalQueueName(destination); var resultIdempotent = cache.GetPhysicalQueueName(result); Assert.AreEqual(expected, result); Assert.AreEqual(expected, resultIdempotent); }
public void ReplacesNonDigitsWithDash(string destination, string expected) { var settings = new SettingsHolder(); var configuration = new TransportConfiguration(settings); var cache = new QueueCache(null, configuration); var result = cache.GetPhysicalQueueName(destination); var resultIdempotent = cache.GetPhysicalQueueName(result); Assert.AreEqual(expected, result); Assert.AreEqual(expected, resultIdempotent); }
public void Preserves_FifoQueue_WithPreTruncate(string destination, string expected) { var settings = new SettingsHolder(); settings.Set(SettingsKeys.PreTruncateQueueNames, true); settings.Set(SettingsKeys.QueueNamePrefix, string.Empty); var configuration = new TransportConfiguration(settings); var cache = new QueueCache(null, configuration); var result = cache.GetPhysicalQueueName(destination); var resultIdempotent = cache.GetPhysicalQueueName(result); Assert.AreEqual(expected, result); Assert.AreEqual(expected, resultIdempotent); }
public void ThrowsWhenLongerThanEightyChars(string destination, string queueNamePrefix) { var settings = new SettingsHolder(); settings.Set(SettingsKeys.QueueNamePrefix, queueNamePrefix); var configuration = new TransportConfiguration(settings); var cache = new QueueCache(null, configuration); var exception = Assert.Throws <Exception>(() => cache.GetPhysicalQueueName(destination)); Assert.That(exception.Message, Contains.Substring("is longer than 80 characters")); }
public static async Task <string> FindMatchingSubscription(this IAmazonSimpleNotificationService snsClient, QueueCache queueCache, Topic topic, string queueName) { var physicalQueueName = queueCache.GetPhysicalQueueName(queueName); ListSubscriptionsByTopicResponse upToAHundredSubscriptions = null; do { upToAHundredSubscriptions = await snsClient.ListSubscriptionsByTopicAsync(topic.TopicArn, upToAHundredSubscriptions?.NextToken) .ConfigureAwait(false); // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator foreach (var upToAHundredSubscription in upToAHundredSubscriptions.Subscriptions) { if (upToAHundredSubscription.Endpoint.EndsWith($":{physicalQueueName}", StringComparison.Ordinal)) { return(upToAHundredSubscription.SubscriptionArn); } } } while (upToAHundredSubscriptions.NextToken != null && upToAHundredSubscriptions.Subscriptions.Count > 0); return(null); }