Skip to content

Commit 67f78ef

Browse files
Saibamenlukebakken
authored andcommitted
Back-port #1616 to 6.x
Fixes #1617 Update RecordedConsumer.cs Update RecordedExchange.cs Update RecordedQueue.cs Update projects/RabbitMQ.Client/client/impl/RecordedBinding.cs Update projects/RabbitMQ.Client/client/impl/RecordedConsumer.cs Update projects/RabbitMQ.Client/client/impl/RecordedExchange.cs Update projects/RabbitMQ.Client/client/impl/RecordedQueue.cs Update projects/RabbitMQ.Client/client/impl/RecordedConsumer.cs Update projects/RabbitMQ.Client/client/impl/RecordedBinding.cs Update projects/RabbitMQ.Client/client/impl/RecordedExchange.cs Update projects/RabbitMQ.Client/client/impl/RecordedQueue.cs Update `TestRecoveringConsumerHandlerOnConnection_EventArgumentsArePassedDown` Update projects/Unit/TestConnectionRecovery.cs
1 parent 8f32ba3 commit 67f78ef

File tree

5 files changed

+49
-9
lines changed

5 files changed

+49
-9
lines changed

projects/RabbitMQ.Client/client/impl/RecordedBinding.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ public override string ToString()
8585

8686
public RecordedBinding WithArguments(IDictionary<string, object> value)
8787
{
88-
Arguments = value;
88+
if (value is null)
89+
{
90+
Arguments = null;
91+
}
92+
else
93+
{
94+
Arguments = new Dictionary<string, object>(value);
95+
}
96+
8997
return this;
9098
}
9199

projects/RabbitMQ.Client/client/impl/RecordedConsumer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,15 @@ public string Recover(IModel channelToUse)
9797

9898
public RecordedConsumer WithArguments(IDictionary<string, object> value)
9999
{
100-
Arguments = value;
100+
if (value is null)
101+
{
102+
Arguments = null;
103+
}
104+
else
105+
{
106+
Arguments = new Dictionary<string, object>(value);
107+
}
108+
101109
return this;
102110
}
103111

projects/RabbitMQ.Client/client/impl/RecordedExchange.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ public override string ToString()
5757

5858
public RecordedExchange WithArguments(IDictionary<string, object> value)
5959
{
60-
Arguments = value;
60+
if (value is null)
61+
{
62+
Arguments = null;
63+
}
64+
else
65+
{
66+
Arguments = new Dictionary<string, object>(value);
67+
}
68+
6169
return this;
6270
}
6371

projects/RabbitMQ.Client/client/impl/RecordedQueue.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,15 @@ protected string NameToUseForRecovery
6666

6767
public RecordedQueue WithArguments(IDictionary<string, object> value)
6868
{
69-
Arguments = value;
69+
if (value is null)
70+
{
71+
Arguments = null;
72+
}
73+
else
74+
{
75+
Arguments = new Dictionary<string, object>(value);
76+
}
77+
7078
return this;
7179
}
7280

projects/Unit/TestConnectionRecovery.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,17 @@ public void TestRecoveringConsumerHandlerOnConnection()
744744
[Test]
745745
public void TestRecoveringConsumerHandlerOnConnection_EventArgumentsArePassedDown()
746746
{
747-
var myArgs = new Dictionary<string, object> { { "first-argument", "some-value" } };
747+
const string key = "first-argument";
748+
const string value = "some-value";
749+
750+
IDictionary<string, object> arguments = new Dictionary<string, object>
751+
{
752+
{ key, value }
753+
};
754+
748755
string q = Model.QueueDeclare(GenerateQueueName(), false, false, false, null).QueueName;
749756
var cons = new EventingBasicConsumer(Model);
750-
string expectedCTag = Model.BasicConsume(cons, q, arguments: myArgs);
757+
string expectedCTag = Model.BasicConsume(cons, q, arguments: arguments);
751758

752759
bool ctagMatches = false;
753760
bool consumerArgumentMatches = false;
@@ -757,14 +764,15 @@ public void TestRecoveringConsumerHandlerOnConnection_EventArgumentsArePassedDow
757764
// passed to a CallbackExceptionHandler, instead of failing the test. Instead, we have to do this trick
758765
// and assert in the test function.
759766
ctagMatches = args.ConsumerTag == expectedCTag;
760-
consumerArgumentMatches = (string)args.ConsumerArguments["first-argument"] == "some-value";
761-
args.ConsumerArguments["first-argument"] = "event-handler-set-this-value";
767+
consumerArgumentMatches = (string)args.ConsumerArguments[key] == value;
762768
};
763769

764770
CloseAndWaitForRecovery();
765771
Assert.That(ctagMatches, Is.True, "expected consumer tag to match");
766772
Assert.That(consumerArgumentMatches, Is.True, "expected consumer arguments to match");
767-
Assert.That(myArgs, Does.ContainKey("first-argument").WithValue("event-handler-set-this-value"));
773+
Assert.That(arguments.ContainsKey(key), Is.True);
774+
string actualVal = (string)arguments[key];
775+
Assert.That(actualVal, Is.EqualTo(value));
768776
}
769777

770778
[Test]

0 commit comments

Comments
 (0)