Upgrade to xunit 2.3.0-beta4
This commit is contained in:
parent
27b0f60f09
commit
5b58a6a71d
|
|
@ -7,7 +7,8 @@
|
|||
<NETStandardImplicitPackageVersion>2.0.0-*</NETStandardImplicitPackageVersion>
|
||||
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
|
||||
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
|
||||
<TestSdkVersion>15.3.0-*</TestSdkVersion>
|
||||
<XunitVersion>2.3.0-beta2-*</XunitVersion>
|
||||
<TestSdkVersion>15.3.0</TestSdkVersion>
|
||||
<XunitAnalyzersVersion>0.6.1</XunitAnalyzersVersion>
|
||||
<XunitVersion>2.3.0-beta4-build3742</XunitVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -227,8 +227,8 @@ namespace Microsoft.AspNetCore.Http
|
|||
Assert.True(Assert.IsType<bool>(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<Middleware>(middlewareFactory.Created);
|
||||
Assert.IsType<Middleware>(middlewareFactory.Released);
|
||||
Assert.Same(middlewareFactory.Created, middlewareFactory.Released);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
|
||||
<PackageReference Include="xunit.analyzers" Version="$(XunitAnalyzersVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -283,7 +283,8 @@ namespace Microsoft.AspNetCore.WebUtilities.Test
|
|||
|
||||
return new MemoryStream(data.ToArray());
|
||||
}
|
||||
private static IEnumerable<object[]> HttpRequestNullData()
|
||||
|
||||
public static IEnumerable<object[]> HttpRequestNullData()
|
||||
{
|
||||
yield return new object[] { null, Encoding.UTF8, ArrayPool<byte>.Shared, ArrayPool<char>.Shared };
|
||||
yield return new object[] { new MemoryStream(), null, ArrayPool<byte>.Shared, ArrayPool<char>.Shared };
|
||||
|
|
@ -291,7 +292,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test
|
|||
yield return new object[] { new MemoryStream(), Encoding.UTF8, ArrayPool<byte>.Shared, null };
|
||||
}
|
||||
|
||||
private static IEnumerable<object[]> HttpRequestDisposeData()
|
||||
public static IEnumerable<object[]> HttpRequestDisposeData()
|
||||
{
|
||||
yield return new object[] { new Action<HttpRequestStreamReader>((httpRequestStreamReader) =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test
|
|||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<object[]> HttpResponseStreamWriterData()
|
||||
public static IEnumerable<object[]> HttpResponseStreamWriterData()
|
||||
{
|
||||
yield return new object[] { null, Encoding.UTF8, ArrayPool<byte>.Shared, ArrayPool<char>.Shared };
|
||||
yield return new object[] { new MemoryStream(), null, ArrayPool<byte>.Shared, ArrayPool<char>.Shared };
|
||||
|
|
@ -529,7 +529,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test
|
|||
yield return new object[] { new MemoryStream(), Encoding.UTF8, ArrayPool<byte>.Shared, null };
|
||||
}
|
||||
|
||||
private static IEnumerable<object[]> HttpResponseDisposeData()
|
||||
public static IEnumerable<object[]> HttpResponseDisposeData()
|
||||
{
|
||||
yield return new object[] { new Action<HttpResponseStreamWriter>((httpResponseStreamWriter) =>
|
||||
{
|
||||
|
|
@ -549,7 +549,8 @@ namespace Microsoft.AspNetCore.WebUtilities.Test
|
|||
httpResponseStreamWriter.Flush();
|
||||
})};
|
||||
}
|
||||
private static IEnumerable<object[]> HttpResponseDisposeDataAsync()
|
||||
|
||||
public static IEnumerable<object[]> HttpResponseDisposeDataAsync()
|
||||
{
|
||||
yield return new object[] { new Func<HttpResponseStreamWriter, Task>(async (httpResponseStreamWriter) =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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[""]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<CookieHeaderValue> cookies, string[] input)
|
||||
{
|
||||
IList<CookieHeaderValue> 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<CookieHeaderValue> cookies, string[] input)
|
||||
{
|
||||
IList<CookieHeaderValue> 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<CookieHeaderValue> cookies, string[] input)
|
||||
{
|
||||
IList<CookieHeaderValue> 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<CookieHeaderValue> cookies, string[] input)
|
||||
public void CookieHeaderValue_ParseStrictList_ThrowsForAnyInvalidValues(
|
||||
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
|
||||
IList<CookieHeaderValue> cookies,
|
||||
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
|
||||
string[] input)
|
||||
{
|
||||
Assert.Throws<FormatException>(() => CookieHeaderValue.ParseStrictList(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(ListWithInvalidCookieHeaderDataSet))]
|
||||
public void CookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues(IList<CookieHeaderValue> cookies, string[] input)
|
||||
public void CookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues(
|
||||
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
|
||||
IList<CookieHeaderValue> cookies,
|
||||
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
|
||||
string[] input)
|
||||
{
|
||||
IList<CookieHeaderValue> results;
|
||||
var result = CookieHeaderValue.TryParseStrictList(input, out results);
|
||||
var result = CookieHeaderValue.TryParseStrictList(input, out var results);
|
||||
Assert.Null(results);
|
||||
Assert.False(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<object[]> ValidStringData()
|
||||
public static IEnumerable<object[]> 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<object[]> InvalidStringData()
|
||||
public static IEnumerable<object[]> InvalidStringData()
|
||||
{
|
||||
yield return new object[] { null };
|
||||
yield return new object[] { string.Empty };
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<SetCookieHeaderValue> cookies, string[] input)
|
||||
{
|
||||
IList<SetCookieHeaderValue> 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<SetCookieHeaderValue> cookies, string[] input)
|
||||
{
|
||||
IList<SetCookieHeaderValue> 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<SetCookieHeaderValue> cookies, string[] input)
|
||||
{
|
||||
IList<SetCookieHeaderValue> 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<SetCookieHeaderValue> cookies, string[] input)
|
||||
public void SetCookieHeaderValue_ParseStrictList_ThrowsForAnyInvalidValues(
|
||||
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
|
||||
IList<SetCookieHeaderValue> cookies,
|
||||
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
|
||||
string[] input)
|
||||
{
|
||||
Assert.Throws<FormatException>(() => SetCookieHeaderValue.ParseStrictList(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(ListWithInvalidSetCookieHeaderDataSet))]
|
||||
public void SetCookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues(IList<SetCookieHeaderValue> cookies, string[] input)
|
||||
public void SetCookieHeaderValue_TryParseStrictList_FailsForAnyInvalidValues(
|
||||
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
|
||||
IList<SetCookieHeaderValue> cookies,
|
||||
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
|
||||
string[] input)
|
||||
{
|
||||
IList<SetCookieHeaderValue> results;
|
||||
bool result = SetCookieHeaderValue.TryParseStrictList(input, out results);
|
||||
bool result = SetCookieHeaderValue.TryParseStrictList(input, out var results);
|
||||
Assert.Null(results);
|
||||
Assert.False(result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue