Skip to content

Commit 4be893c

Browse files
committed
* Add QueueName type and tests.
1 parent f802ba4 commit 4be893c

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

projects/RabbitMQ.Client/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ RabbitMQ.Client.PublicationAddress
654654
RabbitMQ.Client.PublicationAddress.PublicationAddress(string exchangeType, string exchangeName, string routingKey) -> void
655655
RabbitMQ.Client.QueueDeclareOk
656656
RabbitMQ.Client.QueueDeclareOk.QueueDeclareOk(string queueName, uint messageCount, uint consumerCount) -> void
657+
RabbitMQ.Client.QueueName
657658
RabbitMQ.Client.RabbitMQActivitySource
658659
RabbitMQ.Client.ReadOnlyBasicProperties
659660
RabbitMQ.Client.ReadOnlyBasicProperties.AppId.get -> string
@@ -932,6 +933,7 @@ virtual RabbitMQ.Client.TcpClientAdapter.ReceiveTimeout.set -> void
932933
~RabbitMQ.Client.IConnectionFactory.CreateConnectionAsync(System.Collections.Generic.IEnumerable<string> hostnames, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
933934
~RabbitMQ.Client.IConnectionFactory.CreateConnectionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IConnection>
934935
~RabbitMQ.Client.ICredentialsRefresher.Register(RabbitMQ.Client.ICredentialsProvider provider, RabbitMQ.Client.ICredentialsRefresher.NotifyCredentialRefreshedAsync callback) -> RabbitMQ.Client.ICredentialsProvider
936+
~RabbitMQ.Client.QueueName.QueueName(string exchangeName) -> void
935937
~RabbitMQ.Client.TimerBasedCredentialRefresher.Register(RabbitMQ.Client.ICredentialsProvider provider, RabbitMQ.Client.ICredentialsRefresher.NotifyCredentialRefreshedAsync callback) -> RabbitMQ.Client.ICredentialsProvider
936938
~RabbitMQ.Client.TopologyRecoveryExceptionHandler.BindingRecoveryExceptionHandlerAsync.get -> System.Func<RabbitMQ.Client.IRecordedBinding, System.Exception, RabbitMQ.Client.IConnection, System.Threading.Tasks.Task>
937939
~RabbitMQ.Client.TopologyRecoveryExceptionHandler.BindingRecoveryExceptionHandlerAsync.set -> void
@@ -963,5 +965,6 @@ virtual RabbitMQ.Client.TcpClientAdapter.ReceiveTimeout.set -> void
963965
~static RabbitMQ.Client.IConnectionExtensions.CloseAsync(this RabbitMQ.Client.IConnection connection, System.TimeSpan timeout) -> System.Threading.Tasks.Task
964966
~static RabbitMQ.Client.IConnectionExtensions.CloseAsync(this RabbitMQ.Client.IConnection connection, ushort reasonCode, string reasonText) -> System.Threading.Tasks.Task
965967
~static RabbitMQ.Client.IConnectionExtensions.CloseAsync(this RabbitMQ.Client.IConnection connection, ushort reasonCode, string reasonText, System.TimeSpan timeout) -> System.Threading.Tasks.Task
968+
~static RabbitMQ.Client.QueueName.explicit operator RabbitMQ.Client.QueueName(string value) -> RabbitMQ.Client.QueueName
966969
~virtual RabbitMQ.Client.AsyncDefaultBasicConsumer.HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, System.ReadOnlyMemory<byte> exchange, System.ReadOnlyMemory<byte> routingKey, in RabbitMQ.Client.ReadOnlyBasicProperties properties, System.ReadOnlyMemory<byte> body) -> System.Threading.Tasks.Task
967970
~virtual RabbitMQ.Client.DefaultBasicConsumer.HandleBasicDeliverAsync(string consumerTag, ulong deliveryTag, bool redelivered, System.ReadOnlyMemory<byte> exchange, System.ReadOnlyMemory<byte> routingKey, RabbitMQ.Client.ReadOnlyBasicProperties properties, System.ReadOnlyMemory<byte> body) -> System.Threading.Tasks.Task

projects/RabbitMQ.Client/client/api/AmqpString.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,25 @@ public static explicit operator ExchangeName(string value)
9393
return new ExchangeName(value);
9494
}
9595
}
96+
97+
/*
98+
* From the spec:
99+
* <domain name="queue-name" type="shortstr" label="queue name">
100+
* <doc> The queue name identifies the queue within the vhost. In methods where the queue name may be blank, and that has no specific significance, this refers to the 'current' queue for the channel, meaning the last queue that the client declared on the channel. If the client did not declare a queue, and the method needs a queue name, this will result in a 502 (syntax error) channel exception. </doc>
101+
* <assert check="length" value="127"/>
102+
* <assert check="regexp" value="^[a-zA-Z0-9-_.:]*$"/>
103+
* </domain>
104+
*/
105+
public class QueueName : AmqpString
106+
{
107+
public QueueName(string exchangeName)
108+
: base(exchangeName, 127, Encoding.ASCII, "^[a-zA-Z0-9-_.:]*$")
109+
{
110+
}
111+
112+
public static explicit operator QueueName(string value)
113+
{
114+
return new QueueName(value);
115+
}
116+
}
96117
}

projects/Test/Unit/TestAmqpString.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,24 @@ public void TestInvalidExchangeNameThrows(string arg)
5555
{
5656
Assert.Throws<ArgumentOutOfRangeException>(() => new ExchangeName(arg));
5757
}
58+
59+
[Theory]
60+
[InlineData("queue-ABC:123.abc_456")]
61+
[InlineData("6PiY80XbjBKnY39R947i2s03cAg261412IS1FzS4uEoJJ6cWZ50P0SJ3S4yqvzx0n4TN4NsROlWyEwaUG4I5Glrj1mI2N28QGbkf5t8Kyo7EavaqME5TrvhPxtJGY1p")]
62+
[InlineData("foo_bar_baz")]
63+
public void TestValidQueueNames(string arg)
64+
{
65+
var e = new QueueName(arg);
66+
Assert.Equal(e, arg);
67+
}
68+
69+
[Theory]
70+
[InlineData("exchange-Евгений")]
71+
[InlineData("6PiY80XbjBK9nY39R947i2s03cAg261412IS1FzS4uEoJJ6cWZ50P0SJ3S4yqvzx0n4TN4NsROlWyEwaUG4I5Glrj1mI2N28QGbkf5t8Kyo7EavaqME5TrvhPxtJGY1p")]
72+
[InlineData("foo/bar%baz")]
73+
public void TestInvalidQueueNameThrows(string arg)
74+
{
75+
Assert.Throws<ArgumentOutOfRangeException>(() => new QueueName(arg));
76+
}
5877
}
5978
}

0 commit comments

Comments
 (0)