|
30 | 30 | //---------------------------------------------------------------------------
|
31 | 31 |
|
32 | 32 | using System.Collections.Generic;
|
| 33 | +using System.Net.Sockets; |
33 | 34 | using RabbitMQ.Client.Exceptions;
|
| 35 | +using RabbitMQ.Client.Impl; |
34 | 36 | using Xunit;
|
35 | 37 |
|
36 | 38 | namespace RabbitMQ.Client.Unit
|
@@ -69,6 +71,34 @@ public void TestProperties()
|
69 | 71 | Assert.Equal(cf.Endpoint.MaxMessageSize, mms);
|
70 | 72 | }
|
71 | 73 |
|
| 74 | + [Fact] |
| 75 | + public void TestConnectionFactoryWithCustomSocketFactory() |
| 76 | + { |
| 77 | + const int bufsz = 1024; |
| 78 | + |
| 79 | + ConnectionFactory cf = new() |
| 80 | + { |
| 81 | + SocketFactory = (AddressFamily af) => |
| 82 | + { |
| 83 | + var socket = new Socket(af, SocketType.Stream, ProtocolType.Tcp) |
| 84 | + { |
| 85 | + SendBufferSize = bufsz, |
| 86 | + ReceiveBufferSize = bufsz, |
| 87 | + NoDelay = false |
| 88 | + }; |
| 89 | + return new TcpClientAdapter(socket); |
| 90 | + } |
| 91 | + }; |
| 92 | + |
| 93 | + ITcpClient c = cf.SocketFactory(AddressFamily.InterNetwork); |
| 94 | + Assert.IsType<TcpClientAdapter>(c); |
| 95 | + TcpClientAdapter tcpClientAdapter = (TcpClientAdapter)c; |
| 96 | + Socket s = tcpClientAdapter.Client; |
| 97 | + Assert.Equal(bufsz, s.ReceiveBufferSize); |
| 98 | + Assert.Equal(bufsz, s.SendBufferSize); |
| 99 | + Assert.False(s.NoDelay); |
| 100 | + } |
| 101 | + |
72 | 102 | [Fact]
|
73 | 103 | public void TestCreateConnectionUsesSpecifiedPort()
|
74 | 104 | {
|
|
0 commit comments