diff --git a/build/dependencies.props b/build/dependencies.props index 4e451e9dc7..a5fb570275 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -7,7 +7,8 @@ 2.0.0-* 2.0.0-* 2.0.0-* - 15.3.0-* - 2.3.0-beta2-* + 15.3.0 + 0.6.1 + 2.3.0-beta4-build3742 diff --git a/test/Microsoft.AspNetCore.Authentication.Core.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Core.Test/TokenExtensionTests.cs index 21b78e5276..7215d526e9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Core.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Core.Test/TokenExtensionTests.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Authentication Assert.Null(props.GetTokenValue("One")); Assert.Null(props.GetTokenValue("Two")); Assert.Null(props.GetTokenValue("Three")); - Assert.Equal(1, props.GetTokens().Count()); + Assert.Single(props.GetTokens()); } [Fact] diff --git a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/PathStringTests.cs b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/PathStringTests.cs index ad070afa02..2d3c6e23f0 100644 --- a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/PathStringTests.cs +++ b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/PathStringTests.cs @@ -138,8 +138,7 @@ namespace Microsoft.AspNetCore.Http var source = new PathString(sourcePath); var test = new PathString(testPath); - PathString remaining; - var result = source.StartsWithSegments(test, out remaining); + var result = source.StartsWithSegments(test, out var remaining); Assert.Equal(expectedResult, result); } @@ -181,26 +180,33 @@ namespace Microsoft.AspNetCore.Http var source = new PathString(sourcePath); var test = new PathString(testPath); - PathString remaining; - var result = source.StartsWithSegments(test, comparison, out remaining); + var result = source.StartsWithSegments(test, comparison, out var remaining); Assert.Equal(expectedResult, result); } [Theory] - [InlineData("unreserved", "/abc123.-_~", "/abc123.-_~")] - [InlineData("colon", "/:", "/:")] - [InlineData("at", "/@", "/@")] - [InlineData("sub-delims", "/!$&'()*+,;=", "/!$&'()*+,;=")] - [InlineData("reserved", "/?#[]", "/%3F%23%5B%5D")] - [InlineData("pct-encoding", "/单行道", "/%E5%8D%95%E8%A1%8C%E9%81%93")] - [InlineData("mixed1", "/index/单行道=(x*y)[abc]", "/index/%E5%8D%95%E8%A1%8C%E9%81%93=(x*y)%5Babc%5D")] - [InlineData("mixed2", "/index/单行道=(x*y)[abc]_", "/index/%E5%8D%95%E8%A1%8C%E9%81%93=(x*y)%5Babc%5D_")] - [InlineData("encoded", "/http%3a%2f%2f[foo]%3A5000/", "/http%3a%2f%2f%5Bfoo%5D%3A5000/")] - [InlineData("encoded", "/http%3a%2f%2f[foo]%3A5000/%", "/http%3a%2f%2f%5Bfoo%5D%3A5000/%25")] - [InlineData("encoded", "/http%3a%2f%2f[foo]%3A5000/%2", "/http%3a%2f%2f%5Bfoo%5D%3A5000/%252")] - [InlineData("encoded", "/http%3a%2f%2f[foo]%3A5000/%2F", "/http%3a%2f%2f%5Bfoo%5D%3A5000/%2F")] - public void ToUriComponentEscapeCorrectly(string category, string input, string expected) + // unreserved + [InlineData("/abc123.-_~", "/abc123.-_~")] + // colon + [InlineData("/:", "/:")] + // at + [InlineData("/@", "/@")] + // sub-delims + [InlineData("/!$&'()*+,;=", "/!$&'()*+,;=")] + // reserved + [InlineData("/?#[]", "/%3F%23%5B%5D")] + // pct-encoding + [InlineData("/单行道", "/%E5%8D%95%E8%A1%8C%E9%81%93")] + // mixed + [InlineData("/index/单行道=(x*y)[abc]", "/index/%E5%8D%95%E8%A1%8C%E9%81%93=(x*y)%5Babc%5D")] + [InlineData("/index/单行道=(x*y)[abc]_", "/index/%E5%8D%95%E8%A1%8C%E9%81%93=(x*y)%5Babc%5D_")] + // encoded + [InlineData("/http%3a%2f%2f[foo]%3A5000/", "/http%3a%2f%2f%5Bfoo%5D%3A5000/")] + [InlineData("/http%3a%2f%2f[foo]%3A5000/%", "/http%3a%2f%2f%5Bfoo%5D%3A5000/%25")] + [InlineData("/http%3a%2f%2f[foo]%3A5000/%2", "/http%3a%2f%2f%5Bfoo%5D%3A5000/%252")] + [InlineData("/http%3a%2f%2f[foo]%3A5000/%2F", "/http%3a%2f%2f%5Bfoo%5D%3A5000/%2F")] + public void ToUriComponentEscapeCorrectly(string input, string expected) { var path = new PathString(input); diff --git a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs index 7bf6ad4a74..342aa54a06 100644 --- a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs +++ b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/UseMiddlewareTest.cs @@ -227,8 +227,8 @@ namespace Microsoft.AspNetCore.Http Assert.True(Assert.IsType(context.Items["after"])); Assert.NotNull(middlewareFactory.Created); Assert.NotNull(middlewareFactory.Released); - Assert.IsType(typeof(Middleware), middlewareFactory.Created); - Assert.IsType(typeof(Middleware), middlewareFactory.Released); + Assert.IsType(middlewareFactory.Created); + Assert.IsType(middlewareFactory.Released); Assert.Same(middlewareFactory.Created, middlewareFactory.Released); } diff --git a/test/Microsoft.AspNetCore.Http.Tests/DefaultHttpContextTests.cs b/test/Microsoft.AspNetCore.Http.Tests/DefaultHttpContextTests.cs index 6463880f6e..33f73cf191 100644 --- a/test/Microsoft.AspNetCore.Http.Tests/DefaultHttpContextTests.cs +++ b/test/Microsoft.AspNetCore.Http.Tests/DefaultHttpContextTests.cs @@ -84,21 +84,21 @@ namespace Microsoft.AspNetCore.Http { var context = new DefaultHttpContext(new FeatureCollection()); Assert.NotNull(context.User); - Assert.Equal(1, context.User.Identities.Count()); + Assert.Single(context.User.Identities); Assert.True(object.ReferenceEquals(context.User, context.User)); Assert.False(context.User.Identity.IsAuthenticated); Assert.True(string.IsNullOrEmpty(context.User.Identity.AuthenticationType)); context.User = null; Assert.NotNull(context.User); - Assert.Equal(1, context.User.Identities.Count()); + Assert.Single(context.User.Identities); Assert.True(object.ReferenceEquals(context.User, context.User)); Assert.False(context.User.Identity.IsAuthenticated); Assert.True(string.IsNullOrEmpty(context.User.Identity.AuthenticationType)); context.User = new ClaimsPrincipal(); Assert.NotNull(context.User); - Assert.Equal(0, context.User.Identities.Count()); + Assert.Empty(context.User.Identities); Assert.True(object.ReferenceEquals(context.User, context.User)); Assert.Null(context.User.Identity); diff --git a/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj b/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj index 47fc0bafde..5ec662d085 100644 --- a/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj +++ b/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj @@ -15,6 +15,7 @@ + diff --git a/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpRequestStreamReaderTest.cs b/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpRequestStreamReaderTest.cs index ee4d2f2bdc..062342fa4c 100644 --- a/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpRequestStreamReaderTest.cs +++ b/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpRequestStreamReaderTest.cs @@ -283,7 +283,8 @@ namespace Microsoft.AspNetCore.WebUtilities.Test return new MemoryStream(data.ToArray()); } - private static IEnumerable HttpRequestNullData() + + public static IEnumerable HttpRequestNullData() { yield return new object[] { null, Encoding.UTF8, ArrayPool.Shared, ArrayPool.Shared }; yield return new object[] { new MemoryStream(), null, ArrayPool.Shared, ArrayPool.Shared }; @@ -291,7 +292,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test yield return new object[] { new MemoryStream(), Encoding.UTF8, ArrayPool.Shared, null }; } - private static IEnumerable HttpRequestDisposeData() + public static IEnumerable HttpRequestDisposeData() { yield return new object[] { new Action((httpRequestStreamReader) => { diff --git a/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs b/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs index d0c94f9739..7847e1384e 100644 --- a/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs +++ b/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs @@ -521,7 +521,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test } } - private static IEnumerable HttpResponseStreamWriterData() + public static IEnumerable HttpResponseStreamWriterData() { yield return new object[] { null, Encoding.UTF8, ArrayPool.Shared, ArrayPool.Shared }; yield return new object[] { new MemoryStream(), null, ArrayPool.Shared, ArrayPool.Shared }; @@ -529,7 +529,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test yield return new object[] { new MemoryStream(), Encoding.UTF8, ArrayPool.Shared, null }; } - private static IEnumerable HttpResponseDisposeData() + public static IEnumerable HttpResponseDisposeData() { yield return new object[] { new Action((httpResponseStreamWriter) => { @@ -549,7 +549,8 @@ namespace Microsoft.AspNetCore.WebUtilities.Test httpResponseStreamWriter.Flush(); })}; } - private static IEnumerable HttpResponseDisposeDataAsync() + + public static IEnumerable HttpResponseDisposeDataAsync() { yield return new object[] { new Func(async (httpResponseStreamWriter) => { diff --git a/test/Microsoft.AspNetCore.WebUtilities.Tests/MultipartReaderTests.cs b/test/Microsoft.AspNetCore.WebUtilities.Tests/MultipartReaderTests.cs index 90c2ffdfcb..d66ea98fed 100644 --- a/test/Microsoft.AspNetCore.WebUtilities.Tests/MultipartReaderTests.cs +++ b/test/Microsoft.AspNetCore.WebUtilities.Tests/MultipartReaderTests.cs @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); @@ -156,7 +156,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); @@ -173,7 +173,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); @@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); @@ -216,7 +216,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); @@ -242,7 +242,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); @@ -289,7 +289,7 @@ namespace Microsoft.AspNetCore.WebUtilities //first section can be read successfully var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\"", section.Headers["Content-Disposition"][0]); var read = section.Body.Read(buffer, 0, buffer.Length); Assert.Equal("text default", GetString(buffer, read)); @@ -336,7 +336,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\" filename=\"a\uFFFD!.txt\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); @@ -371,7 +371,7 @@ namespace Microsoft.AspNetCore.WebUtilities var section = await reader.ReadNextSectionAsync(); Assert.NotNull(section); - Assert.Equal(1, section.Headers.Count); + Assert.Single(section.Headers); Assert.Equal("form-data; name=\"text\" filename=\"a\uFFFDU.txt\"", section.Headers["Content-Disposition"][0]); var buffer = new MemoryStream(); await section.Body.CopyToAsync(buffer); diff --git a/test/Microsoft.AspNetCore.WebUtilities.Tests/QueryHelpersTests.cs b/test/Microsoft.AspNetCore.WebUtilities.Tests/QueryHelpersTests.cs index fde7ece69b..5607ab87aa 100644 --- a/test/Microsoft.AspNetCore.WebUtilities.Tests/QueryHelpersTests.cs +++ b/test/Microsoft.AspNetCore.WebUtilities.Tests/QueryHelpersTests.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.WebUtilities public void ParseQueryWithEmptyKeyWorks() { var collection = QueryHelpers.ParseQuery("?=value1&="); - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(new[] { "value1", "" }, collection[""]); } diff --git a/test/Microsoft.Net.Http.Headers.Tests/CookieHeaderValueTest.cs b/test/Microsoft.Net.Http.Headers.Tests/CookieHeaderValueTest.cs index 4b320c0e06..416441991d 100644 --- a/test/Microsoft.Net.Http.Headers.Tests/CookieHeaderValueTest.cs +++ b/test/Microsoft.Net.Http.Headers.Tests/CookieHeaderValueTest.cs @@ -223,9 +223,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(CookieHeaderDataSet))] public void CookieHeaderValue_TryParse_AcceptsValidValues(CookieHeaderValue cookie, string expectedValue) { - CookieHeaderValue header; - var result = CookieHeaderValue.TryParse(expectedValue, out header); - Assert.True(result); + Assert.True(CookieHeaderValue.TryParse(expectedValue, out var header)); Assert.Equal(cookie, header); Assert.Equal(expectedValue, header.ToString()); @@ -242,10 +240,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(InvalidCookieHeaderDataSet))] public void CookieHeaderValue_TryParse_RejectsInvalidValues(string value) { - CookieHeaderValue header; - var result = CookieHeaderValue.TryParse(value, out header); - - Assert.False(result); + Assert.False(CookieHeaderValue.TryParse(value, out var _)); } [Theory] @@ -270,8 +265,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(ListOfCookieHeaderDataSet))] public void CookieHeaderValue_TryParseList_AcceptsValidValues(IList cookies, string[] input) { - IList results; - var result = CookieHeaderValue.TryParseList(input, out results); + var result = CookieHeaderValue.TryParseList(input, out var results); Assert.True(result); Assert.Equal(cookies, results); @@ -281,8 +275,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(ListOfCookieHeaderDataSet))] public void CookieHeaderValue_TryParseStrictList_AcceptsValidValues(IList cookies, string[] input) { - IList results; - var result = CookieHeaderValue.TryParseStrictList(input, out results); + var result = CookieHeaderValue.TryParseStrictList(input, out var results); Assert.True(result); Assert.Equal(cookies, results); @@ -301,25 +294,31 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(ListWithInvalidCookieHeaderDataSet))] public void CookieHeaderValue_TryParseList_ExcludesInvalidValues(IList cookies, string[] input) { - IList results; - var result = CookieHeaderValue.TryParseList(input, out results); + var result = CookieHeaderValue.TryParseList(input, out var results); Assert.Equal(cookies, results); Assert.Equal(cookies?.Count > 0, result); } [Theory] [MemberData(nameof(ListWithInvalidCookieHeaderDataSet))] - public void CookieHeaderValue_ParseStrictList_ThrowsForAnyInvalidValues(IList cookies, string[] input) + public void CookieHeaderValue_ParseStrictList_ThrowsForAnyInvalidValues( +#pragma warning disable xUnit1026 // Theory methods should use all of their parameters + IList cookies, +#pragma warning restore xUnit1026 // Theory methods should use all of their parameters + string[] input) { Assert.Throws(() => CookieHeaderValue.ParseStrictList(input)); } [Theory] [MemberData(nameof(ListWithInvalidCookieHeaderDataSet))] - public void CookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues(IList cookies, string[] input) + public void CookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues( +#pragma warning disable xUnit1026 // Theory methods should use all of their parameters + IList cookies, +#pragma warning restore xUnit1026 // Theory methods should use all of their parameters + string[] input) { - IList results; - var result = CookieHeaderValue.TryParseStrictList(input, out results); + var result = CookieHeaderValue.TryParseStrictList(input, out var results); Assert.Null(results); Assert.False(result); } diff --git a/test/Microsoft.Net.Http.Headers.Tests/DateParserTest.cs b/test/Microsoft.Net.Http.Headers.Tests/DateParserTest.cs index 83fec06c46..5c211c4368 100644 --- a/test/Microsoft.Net.Http.Headers.Tests/DateParserTest.cs +++ b/test/Microsoft.Net.Http.Headers.Tests/DateParserTest.cs @@ -15,12 +15,11 @@ namespace Microsoft.Net.Http.Headers { // We don't need to validate all possible date values, since they're already tested in HttpRuleParserTest. // Just make sure the parser calls HttpRuleParser methods correctly. - DateTimeOffset result; - Assert.True(HeaderUtilities.TryParseDate(input, out result)); + Assert.True(HeaderUtilities.TryParseDate(input, out var result)); Assert.Equal(expected, result); } - private static IEnumerable ValidStringData() + public static IEnumerable ValidStringData() { yield return new object[] { "Tue, 15 Nov 1994 08:12:31 GMT", new DateTimeOffset(1994, 11, 15, 8, 12, 31, TimeSpan.Zero) }; yield return new object[] { " Sunday, 06-Nov-94 08:49:37 GMT ", new DateTimeOffset(1994, 11, 6, 8, 49, 37, TimeSpan.Zero) }; @@ -32,12 +31,11 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(InvalidStringData))] public void TryParse_SetOfInvalidValueStrings_ReturnsFalse(string input) { - DateTimeOffset result; - Assert.False(HeaderUtilities.TryParseDate(input, out result)); + Assert.False(HeaderUtilities.TryParseDate(input, out var result)); Assert.Equal(new DateTimeOffset(), result); } - private static IEnumerable InvalidStringData() + public static IEnumerable InvalidStringData() { yield return new object[] { null }; yield return new object[] { string.Empty }; diff --git a/test/Microsoft.Net.Http.Headers.Tests/RangeItemHeaderValueTest.cs b/test/Microsoft.Net.Http.Headers.Tests/RangeItemHeaderValueTest.cs index b8818752ac..95598f0a46 100644 --- a/test/Microsoft.Net.Http.Headers.Tests/RangeItemHeaderValueTest.cs +++ b/test/Microsoft.Net.Http.Headers.Tests/RangeItemHeaderValueTest.cs @@ -136,7 +136,7 @@ namespace Microsoft.Net.Http.Headers Assert.True(RangeHeaderValue.TryParse("byte=" + input, out result), input); var ranges = result.Ranges.ToArray(); - Assert.Equal(1, ranges.Length); + Assert.Single(ranges); var range = ranges.First(); diff --git a/test/Microsoft.Net.Http.Headers.Tests/SetCookieHeaderValueTest.cs b/test/Microsoft.Net.Http.Headers.Tests/SetCookieHeaderValueTest.cs index 2a84397bb8..e7e8bf045a 100644 --- a/test/Microsoft.Net.Http.Headers.Tests/SetCookieHeaderValueTest.cs +++ b/test/Microsoft.Net.Http.Headers.Tests/SetCookieHeaderValueTest.cs @@ -326,9 +326,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(SetCookieHeaderDataSet))] public void SetCookieHeaderValue_TryParse_AcceptsValidValues(SetCookieHeaderValue cookie, string expectedValue) { - SetCookieHeaderValue header; - bool result = SetCookieHeaderValue.TryParse(expectedValue, out header); - Assert.True(result); + Assert.True(SetCookieHeaderValue.TryParse(expectedValue, out var header)); Assert.Equal(cookie, header); Assert.Equal(expectedValue, header.ToString()); @@ -345,10 +343,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(InvalidSetCookieHeaderDataSet))] public void SetCookieHeaderValue_TryParse_RejectsInvalidValues(string value) { - SetCookieHeaderValue header; - bool result = SetCookieHeaderValue.TryParse(value, out header); - - Assert.False(result); + Assert.False(SetCookieHeaderValue.TryParse(value, out var _)); } [Theory] @@ -364,8 +359,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(ListOfSetCookieHeaderDataSet))] public void SetCookieHeaderValue_TryParseList_AcceptsValidValues(IList cookies, string[] input) { - IList results; - bool result = SetCookieHeaderValue.TryParseList(input, out results); + bool result = SetCookieHeaderValue.TryParseList(input, out var results); Assert.True(result); Assert.Equal(cookies, results); @@ -384,8 +378,7 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(ListOfSetCookieHeaderDataSet))] public void SetCookieHeaderValue_TryParseStrictList_AcceptsValidValues(IList cookies, string[] input) { - IList results; - bool result = SetCookieHeaderValue.TryParseStrictList(input, out results); + bool result = SetCookieHeaderValue.TryParseStrictList(input, out var results); Assert.True(result); Assert.Equal(cookies, results); @@ -404,25 +397,31 @@ namespace Microsoft.Net.Http.Headers [MemberData(nameof(ListWithInvalidSetCookieHeaderDataSet))] public void SetCookieHeaderValue_TryParseList_ExcludesInvalidValues(IList cookies, string[] input) { - IList results; - bool result = SetCookieHeaderValue.TryParseList(input, out results); + bool result = SetCookieHeaderValue.TryParseList(input, out var results); Assert.Equal(cookies, results); Assert.Equal(cookies?.Count > 0, result); } [Theory] [MemberData(nameof(ListWithInvalidSetCookieHeaderDataSet))] - public void SetCookieHeaderValue_ParseStrictList_ThrowsForAnyInvalidValues(IList cookies, string[] input) + public void SetCookieHeaderValue_ParseStrictList_ThrowsForAnyInvalidValues( +#pragma warning disable xUnit1026 // Theory methods should use all of their parameters + IList cookies, +#pragma warning restore xUnit1026 // Theory methods should use all of their parameters + string[] input) { Assert.Throws(() => SetCookieHeaderValue.ParseStrictList(input)); } [Theory] [MemberData(nameof(ListWithInvalidSetCookieHeaderDataSet))] - public void SetCookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues(IList cookies, string[] input) + public void SetCookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues( +#pragma warning disable xUnit1026 // Theory methods should use all of their parameters + IList cookies, +#pragma warning restore xUnit1026 // Theory methods should use all of their parameters + string[] input) { - IList results; - bool result = SetCookieHeaderValue.TryParseStrictList(input, out results); + bool result = SetCookieHeaderValue.TryParseStrictList(input, out var results); Assert.Null(results); Assert.False(result); }