Skip to content

Commit

Permalink
Servicebus/fix correlation rule filter clone (Azure#19646)
Browse files Browse the repository at this point in the history
* Fix cloning of CorrelationRuleFilter when CorrelationId is missing

Prevent a null value for CorrelationId from throwing an exception when cloning a CorrelationRuleFilter.

* Test cloning of CorrelationRuleFilter without CorrelationId

Co-authored-by: Mikael Kolkinn <mikael.kolkinn@cgi.com>
  • Loading branch information
Mikael Kolkinn and Mikael Kolkinn authored Mar 20, 2021
1 parent 32bf41d commit da17d96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public CorrelationRuleFilter(string correlationId)
}

internal override RuleFilter Clone() =>
new CorrelationRuleFilter(CorrelationId)
new CorrelationRuleFilter
{
CorrelationId = CorrelationId,
MessageId = MessageId,
To = To,
ReplyTo = ReplyTo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void CanCreateRulePropertiesFromFactory()
}

[Test]
public void CanCreateRulePropertiesFromOptions()
public void CanCreateRulePropertiesWithSqlFilterFromOptions()
{
var options = new CreateRuleOptions("rule")
{
Expand All @@ -34,5 +34,24 @@ public void CanCreateRulePropertiesFromOptions()

Assert.AreEqual(options, new CreateRuleOptions(properties));
}

[Test]
public void CanCreateRulePropertiesWithCorrelationFilterFromOptions()
{
var options = new CreateRuleOptions("rule")
{
Filter = new CorrelationRuleFilter
{
ApplicationProperties =
{
{"propertyName", "value"}
}
},
Action = new SqlRuleAction("SET a='b'")
};
var properties = new RuleProperties(options);

Assert.AreEqual(options, new CreateRuleOptions(properties));
}
}
}

0 comments on commit da17d96

Please sign in to comment.