From b158c0ae83db8781795ddbf5128d89f24e57e91e Mon Sep 17 00:00:00 2001 From: vinaysurya Date: Thu, 20 Jul 2017 08:15:13 -0700 Subject: [PATCH] Fix Rule Creation Issue (#227) * Fix Rule Creation Issue * Comments * One more test * Appveyor Issue * Appveyor change * Reverting back the appveyor change --- .../Amqp/AmqpMessageConverter.cs | 1 + .../SubscriptionClientTests.cs | 34 ++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.Azure.ServiceBus/Amqp/AmqpMessageConverter.cs b/src/Microsoft.Azure.ServiceBus/Amqp/AmqpMessageConverter.cs index 62efa1b..d7d1339 100644 --- a/src/Microsoft.Azure.ServiceBus/Amqp/AmqpMessageConverter.cs +++ b/src/Microsoft.Azure.ServiceBus/Amqp/AmqpMessageConverter.cs @@ -357,6 +357,7 @@ namespace Microsoft.Azure.ServiceBus.Amqp AmqpMap amqpAction = GetRuleActionMap(description.Action as SqlRuleAction); ruleDescriptionMap[ManagementConstants.Properties.SqlRuleAction] = amqpAction; + ruleDescriptionMap[ManagementConstants.Properties.RuleName] = description.Name; return ruleDescriptionMap; } diff --git a/test/Microsoft.Azure.ServiceBus.UnitTests/SubscriptionClientTests.cs b/test/Microsoft.Azure.ServiceBus.UnitTests/SubscriptionClientTests.cs index 299cdb7..0dcf00e 100644 --- a/test/Microsoft.Azure.ServiceBus.UnitTests/SubscriptionClientTests.cs +++ b/test/Microsoft.Azure.ServiceBus.UnitTests/SubscriptionClientTests.cs @@ -38,9 +38,9 @@ namespace Microsoft.Azure.ServiceBus.UnitTests { await subscriptionClient.RemoveRuleAsync(RuleDescription.DefaultRuleName); } - catch + catch (Exception e) { - // ignored + TestUtility.Log($"Remove Default Rule failed with Exception: {e.Message}"); } await subscriptionClient.AddRuleAsync(new RuleDescription @@ -64,8 +64,16 @@ namespace Microsoft.Azure.ServiceBus.UnitTests } finally { - await subscriptionClient.RemoveRuleAsync("RedCorrelation"); - await subscriptionClient.AddRuleAsync(RuleDescription.DefaultRuleName, new TrueFilter()); + try + { + await subscriptionClient.RemoveRuleAsync("RedCorrelation"); + await subscriptionClient.AddRuleAsync(RuleDescription.DefaultRuleName, new TrueFilter()); + } + catch (Exception e) + { + TestUtility.Log($" Cleanup failed with Exception: {e.Message}"); + } + await subscriptionClient.CloseAsync(); await topicClient.CloseAsync(); } @@ -89,9 +97,9 @@ namespace Microsoft.Azure.ServiceBus.UnitTests { await subscriptionClient.RemoveRuleAsync(RuleDescription.DefaultRuleName); } - catch + catch(Exception e) { - // ignored + TestUtility.Log($"Remove Default Rule failed with: {e.Message}"); } await subscriptionClient.AddRuleAsync(new RuleDescription @@ -121,12 +129,20 @@ namespace Microsoft.Azure.ServiceBus.UnitTests var messages = await subscriptionClient.InnerSubscriptionClient.InnerReceiver.ReceiveAsync(maxMessageCount: 2); Assert.NotNull(messages); Assert.True(messages.Count == 1); - Assert.True(messageId2.Equals(messages.First().MessageId)); + Assert.True(messageId2.Equals(messages.First().MessageId)); } finally { - await subscriptionClient.RemoveRuleAsync("RedSql"); - await subscriptionClient.AddRuleAsync(RuleDescription.DefaultRuleName, new TrueFilter()); + try + { + await subscriptionClient.RemoveRuleAsync("RedSql"); + await subscriptionClient.AddRuleAsync(RuleDescription.DefaultRuleName, new TrueFilter()); + } + catch (Exception e) + { + TestUtility.Log($" Cleanup failed with Exception: {e.Message}"); + } + await subscriptionClient.CloseAsync(); await topicClient.CloseAsync(); }