Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Add fixes for problems discovered by xunit.analyzers #1999

Merged
merged 3 commits into from
Aug 16, 2017
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
2 changes: 1 addition & 1 deletion test/Kestrel.Core.Tests/FrameConnectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ public async Task StartRequestProcessingCreatesLogScopeWithConnectionId()

await _frameConnection.StopAsync().TimeoutAfter(TimeSpan.FromSeconds(5));

Assert.Equal(1, scopeObjects.Count);
Assert.Single(scopeObjects);
var pairs = scopeObjects[0].ToDictionary(p => p.Key, p => p.Value);
Assert.True(pairs.ContainsKey("ConnectionId"));
Assert.Equal(_frameConnection.ConnectionId, pairs["ConnectionId"]);
Expand Down
4 changes: 4 additions & 0 deletions test/Kestrel.Core.Tests/FrameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ public async Task TakeStartLineSetsFrameProperties(
string requestLine,
string expectedMethod,
string expectedRawTarget,
// This warns that theory methods should use all of their parameters,
// but this method is using a shared data collection with HttpParserTests.ParsesRequestLine and others.
#pragma warning disable xUnit1026
string expectedRawPath,
#pragma warning restore xUnit1026
string expectedDecodedPath,
string expectedQueryString,
string expectedHttpVersion)
Expand Down
6 changes: 5 additions & 1 deletion test/Kestrel.Core.Tests/HttpParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ public void ParsesRequestLine(
string expectedMethod,
string expectedRawTarget,
string expectedRawPath,
// This warns that theory methods should use all of their parameters,
// but this method is using a shared data collection with FrameTests.TakeStartLineSetsFrameProperties and others.
#pragma warning disable xUnit1026
string expectedDecodedPath,
string expectedQueryString,
#pragma warning restore xUnit1026
string expectedVersion)
{
var parser = CreateParser(Mock.Of<IKestrelTrace>());
Expand Down Expand Up @@ -391,7 +395,7 @@ private void VerifyHeader(
parser.ParseHeaders(requestHandler, buffer, out var consumed, out var examined, out var consumedBytes);

var pairs = requestHandler.Headers.ToArray();
Assert.Equal(1, pairs.Length);
Assert.Single(pairs);
Assert.Equal(headerName, pairs[0].Key);
Assert.Equal(expectedHeaderValue, pairs[0].Value);
Assert.Equal(buffer.End, consumed);
Expand Down
5 changes: 3 additions & 2 deletions test/Kestrel.Core.Tests/HttpUtilitiesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ public void GetsKnownVersion(string input, bool expectedResult, string expectedK
var block = new Span<byte>(Encoding.ASCII.GetBytes(input));

// Act
HttpVersion knownVersion;
var result = block.GetKnownVersion(out knownVersion, out var length);
var result = block.GetKnownVersion(out HttpVersion knownVersion, out var length);
string toString = null;
if (knownVersion != HttpVersion.Unknown)
{
toString = HttpUtilities.VersionToString(knownVersion);
}

// Assert
Assert.Equal(version, knownVersion);
Assert.Equal(expectedResult, result);
Assert.Equal(expectedKnownString, toString);
Assert.Equal(expectedKnownString?.Length ?? 0, length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public async Task DoesNotSupportTls10()
using (var client = new TcpClient())
{
var stream = await OpenSslStream(client, server);
var ex = await Assert.ThrowsAsync(typeof(IOException),
var ex = await Assert.ThrowsAsync<IOException>(
async () => await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls, false));
}
}
Expand Down
5 changes: 2 additions & 3 deletions test/Kestrel.FunctionalTests/RequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,9 +1184,8 @@ await connection.ReceiveForcedEnd(
}
}

[Theory]
[MemberData(nameof(ConnectionAdapterData))]
public async Task HeadersAndStreamsAreReusedAcrossRequests(ListenOptions listenOptions)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is interesting. We've been running this test twice, but listenOptions was never used to make the test inputs different. I traced this one back to a massive refactoring in our tests added by @halter73 here: #1280

[Fact]
public async Task HeadersAndStreamsAreReusedAcrossRequests()
{
var testContext = new TestServiceContext();
var streamCount = 0;
Expand Down