Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Nov 15, 2023
1 parent 55dfc54 commit 7a2fcf0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions projects/Unit/TestConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
//---------------------------------------------------------------------------

using System.Collections.Generic;
using System.Net.Sockets;
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Client.Impl;
using Xunit;

namespace RabbitMQ.Client.Unit
Expand Down Expand Up @@ -69,6 +71,34 @@ public void TestProperties()
Assert.Equal(cf.Endpoint.MaxMessageSize, mms);
}

[Fact]
public void TestConnectionFactoryWithCustomSocketFactory()
{
const int bufsz = 1024;

ConnectionFactory cf = new()
{
SocketFactory = (AddressFamily af) =>
{
var socket = new Socket(af, SocketType.Stream, ProtocolType.Tcp)
{
SendBufferSize = bufsz,
ReceiveBufferSize = bufsz,
NoDelay = false
};
return new TcpClientAdapter(socket);
}
};

ITcpClient c = cf.SocketFactory(AddressFamily.InterNetwork);
Assert.IsType<TcpClientAdapter>(c);
TcpClientAdapter tcpClientAdapter = (TcpClientAdapter)c;
Socket s = tcpClientAdapter.Client;
Assert.Equal(bufsz, s.ReceiveBufferSize);
Assert.Equal(bufsz, s.SendBufferSize);
Assert.False(s.NoDelay);
}

[Fact]
public void TestCreateConnectionUsesSpecifiedPort()
{
Expand Down

0 comments on commit 7a2fcf0

Please sign in to comment.