Skip to content

Commit d639ac6

Browse files
Merge pull request #189 from rabbitmq/rabbitmq-dotnet-client-187
ensure client provided name is properly assigned
2 parents c589855 + 8481def commit d639ac6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

projects/client/RabbitMQ.Client/src/client/impl/Connection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class Connection : IConnection
115115

116116
public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
117117
{
118-
clientProvidedName = clientProvidedName;
118+
this.ClientProvidedName = clientProvidedName;
119119
KnownHosts = null;
120120
FrameMax = 0;
121121
m_factory = factory;

projects/client/Unit/src/unit/TestConnectionFactory.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,30 @@ public void TestCreateConnectionWithClientProvidedNameUsesSpecifiedPort()
9191
cf.Port = 1234;
9292
using(var conn = cf.CreateConnection("some_name"));
9393
}
94+
95+
[Test]
96+
public void TestCreateConnectionWithClientProvidedNameUsesName()
97+
{
98+
var cf = new ConnectionFactory();
99+
cf.AutomaticRecoveryEnabled = false;
100+
using(var conn = cf.CreateConnection("some_name"))
101+
{
102+
Assert.AreEqual("some_name", conn.ClientProvidedName);
103+
Assert.AreEqual("some_name", conn.ClientProperties["connection_name"]);
104+
}
105+
}
94106

107+
[Test]
108+
public void TestCreateConnectionWithClientProvidedNameAndAutorecoveryUsesName()
109+
{
110+
var cf = new ConnectionFactory();
111+
cf.AutomaticRecoveryEnabled = true;
112+
using(var conn = cf.CreateConnection("some_name"))
113+
{
114+
Assert.AreEqual("some_name", conn.ClientProvidedName);
115+
Assert.AreEqual("some_name", conn.ClientProperties["connection_name"]);
116+
}
117+
}
95118
[Test]
96119
public void TestCreateConnectionUsesDefaultPort()
97120
{

0 commit comments

Comments
 (0)