Skip to content

Commit 1bf7154

Browse files
authored
Update TestRecoveringConsumerHandlerOnConnection_EventArgumentsArePassedDown
1 parent af885df commit 1bf7154

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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 = arguments[key];
775+
Assert.That(actualVal, Is.EqualTo(value));
768776
}
769777

770778
[Test]

0 commit comments

Comments
 (0)