Skip to content

increase BufferPtrSendOperation test coverage #38935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void EventSource_EventsRaisedAsExpected()
new SendReceiveApm(null).SendRecv_Stream_TCP(IPAddress.Loopback, false).GetAwaiter();
new SendReceiveApm(null).SendRecv_Stream_TCP(IPAddress.Loopback, true).GetAwaiter();

new NetworkStreamTest().CopyToAsync_AllDataCopied(4096).GetAwaiter().GetResult();
new NetworkStreamTest().CopyToAsync_AllDataCopied(4096, true).GetAwaiter().GetResult();
new NetworkStreamTest().Timeout_ValidData_Roundtrips().GetAwaiter().GetResult();
});
Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,14 @@ await RunWithConnectedNetworkStreamsAsync((server, client) =>
});
}

public static IEnumerable<object[]> CopyToAsync_AllDataCopied_MemberData() =>
from asyncWrite in new bool[] { true, false }
from byteCount in new int[] { 0, 1, 1024, 4096, 4095, 1024 * 1024 }
select new object[] { byteCount, asyncWrite };

[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(1024)]
[InlineData(4096)]
[InlineData(4095)]
[InlineData(1024*1024)]
public async Task CopyToAsync_AllDataCopied(int byteCount)
[MemberData(nameof(CopyToAsync_AllDataCopied_MemberData))]
public async Task CopyToAsync_AllDataCopied(int byteCount, bool asyncWrite)
{
await RunWithConnectedNetworkStreamsAsync(async (server, client) =>
{
Expand All @@ -650,7 +650,16 @@ await RunWithConnectedNetworkStreamsAsync(async (server, client) =>
new Random().NextBytes(dataToCopy);

Task copyTask = client.CopyToAsync(results);
await server.WriteAsync(dataToCopy, 0, dataToCopy.Length);

if (asyncWrite)
{
await server.WriteAsync(dataToCopy, 0, dataToCopy.Length);
}
else
{
server.Write(new ReadOnlySpan<byte>(dataToCopy, 0, dataToCopy.Length));
}

server.Dispose();
await copyTask;

Expand Down