Skip to content

Commit

Permalink
GH-44911: [C#] Choose port numbers dynamically for ArrowStreamWriterT…
Browse files Browse the repository at this point in the history
…ests (#44912)

### What changes are included in this PR?

`ArrowStreamWriterTests.CanWriteToNetworkStream` and `ArrowStreamWriterTests.CanWriteToNetworkStreamAsync` pick ports dynamically instead of hardcoding a static port.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.

Resolves #44911.
* GitHub Issue: #44911

Authored-by: Curt Hagenlocher <[email protected]>
Signed-off-by: Curt Hagenlocher <[email protected]>
  • Loading branch information
CurtHagenlocher authored Dec 3, 2024
1 parent 5e476b3 commit c7e3122
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions csharp/test/Apache.Arrow.Tests/ArrowStreamWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ public void Ctor_LeaveOpenTrue_StreamValidOnDispose()
}

[Theory]
[InlineData(true, 32153)]
[InlineData(false, 32154)]
public void CanWriteToNetworkStream(bool createDictionaryArray, int port)
[InlineData(true)]
[InlineData(false)]
public void CanWriteToNetworkStream(bool createDictionaryArray)
{
RecordBatch originalBatch = TestData.CreateSampleRecordBatch(length: 100, createDictionaryArray: createDictionaryArray);

TcpListener listener = new TcpListener(IPAddress.Loopback, port);
TcpListener listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
int port = ((IPEndPoint)listener.LocalEndpoint).Port;

using (TcpClient sender = new TcpClient())
{
Expand Down Expand Up @@ -92,14 +93,15 @@ public void CanWriteToNetworkStream(bool createDictionaryArray, int port)
}

[Theory]
[InlineData(true, 32155)]
[InlineData(false, 32156)]
public async Task CanWriteToNetworkStreamAsync(bool createDictionaryArray, int port)
[InlineData(true)]
[InlineData(false)]
public async Task CanWriteToNetworkStreamAsync(bool createDictionaryArray)
{
RecordBatch originalBatch = TestData.CreateSampleRecordBatch(length: 100, createDictionaryArray: createDictionaryArray);

TcpListener listener = new TcpListener(IPAddress.Loopback, port);
TcpListener listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
int port = ((IPEndPoint)listener.LocalEndpoint).Port;

using (TcpClient sender = new TcpClient())
{
Expand Down

0 comments on commit c7e3122

Please sign in to comment.