Test Formatting assemblies w/ `net6.0` (#384)
- expand our text matrix to include a modern (and LTS) TFM - change how Formatting test assemblies are found - `netcoreapp` is no longer the only relevant folder prefix - use the latest .NET 6 SDK - install the 2.1.x runtime in the pipeline - don't require .NET in VS - will use binplaced `msbuild` instead - have `git` ignore the new .msbuild/ folder - react to new `Exception.Message`s in `netcoreapp3.1` - handle different formatting of argument info in `ArgumentException.Message`s - handle slightly greater `decimal` precision in a `JsonReaderException.Message` - react to new `Exception.Message`s and other changes in `net6.0` - handle different `Message` in `InvalidOperationException`s about invalid request URIs - react to other changes in `net6.0` - handle inability to mock a `Stream` if a writer passes a `ReadOnlySpan<byte>` in `net6.0` - see moq/moq4#829, moq/moq4#979, and dotnet/runtime#45152 about the issue - skip tests failing due to `HttpResponseMessage` changes - see #386 and dotnet/runtime@b48900f3b3 (which introduced this) - fix coming **Real Soon Now™️** 😁 - nits: - simplify define use now that `NETCOREAPP3_1_OR_GREATER` and so on are available - clean up .gitignore - clean up a few comments and tighten scripting up
This commit is contained in:
Родитель
169d95fc06
Коммит
0f4c62480b
|
@ -1,22 +1,20 @@
|
|||
[Bb]in
|
||||
[Oo]bj
|
||||
[Tt]est[Rr]esults
|
||||
.msbuild/
|
||||
.vs/
|
||||
bin/
|
||||
obj/
|
||||
packages/
|
||||
|
||||
*.[Cc]ache
|
||||
*.binlog
|
||||
*.dll
|
||||
*.dot[Cc]over
|
||||
*.exe
|
||||
*.nupkg
|
||||
*.orig
|
||||
*.psess
|
||||
*.sln.ide
|
||||
*.suo
|
||||
*.user
|
||||
*.[Cc]ache
|
||||
*[Rr]esharper*
|
||||
packages
|
||||
NuGet.exe
|
||||
_[Ss]cripts
|
||||
*.binlog
|
||||
*.exe
|
||||
*.dll
|
||||
*.nupkg
|
||||
*.dot[Cc]over
|
||||
*.vsp
|
||||
*.psess
|
||||
*.orig
|
||||
*.sln.ide
|
||||
.vs/
|
||||
project.lock.json
|
||||
*[Rr]esharper*
|
||||
*launchSettings.json
|
||||
|
|
|
@ -115,12 +115,12 @@
|
|||
XmlPath=$(TestResultsDirectory)%(_TestDLLsXunit.FileName)-XunitResults.xml</Properties>
|
||||
</_XunitProject>
|
||||
|
||||
<_VSTestDLLs Include="bin\$(Configuration)\test\*\netcoreapp*\*.Test.dll"
|
||||
Condition=" '$(BuildPortable)' == 'true' "/>
|
||||
<_XunitProject Include="tools\WebStack.testing.targets"
|
||||
Condition=" '$(BuildPortable)' == 'true' ">
|
||||
<_VSTestDLLs Include="bin\$(Configuration)\test\NetCore\**\*.Test.dll;
|
||||
bin\$(Configuration)\test\NetStandard\**\*.Test.dll"
|
||||
Exclude="bin\$(Configuration)\test\Net*\net4*\*.Test.dll" />
|
||||
<_XunitProject Include="tools\WebStack.testing.targets" Condition=" '$(BuildPortable)' == 'true' ">
|
||||
<Properties>TestAssembly=%(_VSTestDLLs.FullPath);
|
||||
XmlPath=$(TestResultsDirectory)%(_VSTestDLLs.FileName)-NetCoreApp-XunitResults.xml;
|
||||
XmlPath=$(TestResultsDirectory)%(_VSTestDLLs.FileName)-$([System.String]::Copy('%(_VSTestDLLs.RecursiveDir)').Trim('\\'))-XunitResults.xml;
|
||||
UseVSTest=true</Properties>
|
||||
</_XunitProject>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -60,10 +60,16 @@ jobs:
|
|||
- checkout: self
|
||||
clean: true
|
||||
displayName: Checkout
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: Get .NET SDK
|
||||
inputs:
|
||||
useGlobalJson: true
|
||||
- task: UseDotNet@2
|
||||
displayName: Get .NET 2.1 runtime
|
||||
inputs:
|
||||
packageType: runtime
|
||||
version: '2.1.x'
|
||||
|
||||
- script: .\build.cmd EnableSkipStrongNames
|
||||
displayName: Enable SkipStrongNames
|
||||
|
|
38
build.cmd
38
build.cmd
|
@ -2,13 +2,12 @@
|
|||
pushd %~dp0
|
||||
setlocal
|
||||
|
||||
if exist bin goto build
|
||||
if exist bin goto Build
|
||||
mkdir bin
|
||||
|
||||
:Build
|
||||
|
||||
REM Find the most recent 32bit MSBuild.exe on the system. Require v16.0 (installed with VS2019) or later.
|
||||
REM Use `vswhere` for the search because it can find all VS installations.
|
||||
REM Require VS2019 (v16.0) on the system. Use `vswhere` for the search because it can find all VS installations.
|
||||
set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if not exist %vswhere% (
|
||||
set vswhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
|
@ -24,28 +23,33 @@ if not exist %vswhere% (
|
|||
goto BuildFail
|
||||
)
|
||||
|
||||
REM We're fine w/ any .NET SDK newer than 2.1.500 but also need a 2.1.x runtime. Microsoft.Net.Core.Component.SDK.2.1
|
||||
REM actually checks for only the runtime these days.
|
||||
set InstallDir=
|
||||
for /f "usebackq tokens=*" %%i in (`%vswhere% -version 16 -latest -prerelease -products * ^
|
||||
-requires Microsoft.Component.MSBuild ^
|
||||
-requires Microsoft.NetCore.Component.SDK ^
|
||||
-requires Microsoft.Net.Core.Component.SDK.2.1 ^
|
||||
-requires Microsoft.Net.Component.4.5.TargetingPack ^
|
||||
-requires Microsoft.Net.Component.4.5.2.TargetingPack ^
|
||||
-requires Microsoft.Net.Component.4.6.2.TargetingPack ^
|
||||
-property installationPath`) do (
|
||||
set InstallDir="%%i"
|
||||
)
|
||||
|
||||
if not DEFINED InstallDir (
|
||||
echo "Could not find a VS2019 installation with the necessary components (MSBuild, .NET Core 2.1 Runtime, .NET SDK). Please install VS2019 or the missing components."
|
||||
)
|
||||
|
||||
if exist %InstallDir%\MSBuild\Current\Bin\MSBuild.exe (
|
||||
set MSBuild=%InstallDir%\MSBuild\Current\Bin\MSBuild.exe
|
||||
) else (
|
||||
echo Could not find MSBuild.exe. Please install the VS2019 BuildTools component or a workload that includes it.
|
||||
echo "Could not find a VS2019 installation with the necessary components (targeting packs for v4.5, v4.5.2, and v4.6.2)."
|
||||
echo Please install VS2019 or the missing components.
|
||||
goto BuildFail
|
||||
)
|
||||
|
||||
REM Find or install MSBuild. Need v17.4 due to our .NET SDK choice.
|
||||
set "MSBuildVersion=17.4.1"
|
||||
set "Command=[System.Threading.Thread]::CurrentThread.CurrentCulture = ''"
|
||||
set "Command=%Command%; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''"
|
||||
set "Command=%Command%; try { & '%~dp0eng\GetXCopyMSBuild.ps1' %MSBuildVersion%; exit $LASTEXITCODE }"
|
||||
set "Command=%Command% catch { write-host $_; exit 1 }"
|
||||
PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "%Command%"
|
||||
if %ERRORLEVEL% neq 0 goto BuildFail
|
||||
|
||||
REM Add MSBuild to the path.
|
||||
set "PATH=%CD%\.msbuild\%MSBuildVersion%\tools\MSBuild\Current\Bin\;%PATH%"
|
||||
|
||||
REM Configure NuGet operations to work w/in this repo i.e. do not pollute system packages folder.
|
||||
REM Note this causes two copies of packages restored using packages.config to land in this folder e.g.
|
||||
REM StyleCpy.5.0.0/ and stylecop/5.0.0/.
|
||||
|
@ -56,13 +60,13 @@ if DEFINED CI (set Desktop=false) else if DEFINED TEAMCITY_VERSION (set Desktop=
|
|||
|
||||
if "%1" == "" goto BuildDefaults
|
||||
|
||||
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
|
||||
MSBuild Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
|
||||
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary /t:%*
|
||||
if %ERRORLEVEL% neq 0 goto BuildFail
|
||||
goto BuildSuccess
|
||||
|
||||
:BuildDefaults
|
||||
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
|
||||
MSBuild Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
|
||||
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary
|
||||
if %ERRORLEVEL% neq 0 goto BuildFail
|
||||
goto BuildSuccess
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# Lifted from https://github.com/dotnet/arcade/blob/main/eng/common/tools.ps1
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName='Groups')]
|
||||
param(
|
||||
[string]$Version = '17.4.1'
|
||||
)
|
||||
|
||||
Set-StrictMode -Version 2
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Create-Directory ([string[]] $path) {
|
||||
New-Item -Path $path -Force -ItemType 'Directory' | Out-Null
|
||||
}
|
||||
|
||||
function Unzip([string]$zipfile, [string]$outpath) {
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
|
||||
}
|
||||
|
||||
function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install, [string]$ToolsDir) {
|
||||
$packageName = 'RoslynTools.MSBuild'
|
||||
$packageDir = Join-Path $ToolsDir $packageVersion
|
||||
$packagePath = Join-Path $packageDir "$packageName.$packageVersion.nupkg"
|
||||
|
||||
if (!(Test-Path $packageDir)) {
|
||||
if (!$install) {
|
||||
return $null
|
||||
}
|
||||
|
||||
Create-Directory $packageDir
|
||||
|
||||
Write-Host "Downloading $packageName $packageVersion"
|
||||
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit
|
||||
Invoke-WebRequest "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName/$packageVersion/$packageName.$packageVersion.nupkg" -OutFile $packagePath
|
||||
|
||||
Unzip $packagePath $packageDir
|
||||
}
|
||||
|
||||
return Join-Path $packageDir 'tools'
|
||||
}
|
||||
|
||||
InitializeXCopyMSBuild -packageVersion $Version -install $true -ToolsDir (join-path $PWD .msbuild)
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "2.1.818",
|
||||
"version": "6.0.405",
|
||||
"rollForward": "major"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace System.Text
|
|||
}
|
||||
}
|
||||
|
||||
#if NETCOREAPP3_1 || NET5_0_OR_GREATER || NETSTANDARD2_1
|
||||
#if NETCOREAPP3_1_OR_GREATER || NETSTANDARD2_1
|
||||
public override ValueTask DisposeAsync()
|
||||
{
|
||||
if (_innerStream is null)
|
||||
|
|
|
@ -297,7 +297,7 @@ namespace Microsoft.TestCommon
|
|||
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
|
||||
public static ArgumentException ThrowsArgumentNullOrEmpty(Action testCode, string paramName)
|
||||
{
|
||||
return Throws<ArgumentException>(testCode, "Value cannot be null or empty.\r\nParameter name: " + paramName, allowDerivedExceptions: false);
|
||||
return Throws<ArgumentException>(testCode, "Value cannot be null or empty." + GetParameterMessage(paramName), allowDerivedExceptions: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -327,7 +327,7 @@ namespace Microsoft.TestCommon
|
|||
{
|
||||
if (exceptionMessage != null)
|
||||
{
|
||||
exceptionMessage = exceptionMessage + "\r\nParameter name: " + paramName;
|
||||
exceptionMessage = exceptionMessage + GetParameterMessage(paramName);
|
||||
if (actualValue != null)
|
||||
{
|
||||
exceptionMessage += String.Format(CultureReplacer.DefaultCulture, "\r\nActual value was {0}.", actualValue);
|
||||
|
@ -360,7 +360,7 @@ namespace Microsoft.TestCommon
|
|||
{
|
||||
if (exceptionMessage != null)
|
||||
{
|
||||
exceptionMessage = exceptionMessage + "\r\nParameter name: " + paramName;
|
||||
exceptionMessage = exceptionMessage + GetParameterMessage(paramName);
|
||||
if (actualValue != null)
|
||||
{
|
||||
exceptionMessage += String.Format(CultureReplacer.DefaultCulture, "\r\nActual value was {0}.", actualValue);
|
||||
|
@ -500,8 +500,8 @@ namespace Microsoft.TestCommon
|
|||
public static ArgumentException ThrowsInvalidEnumArgument(Action testCode, string paramName, int invalidValue, Type enumType, bool allowDerivedExceptions = false)
|
||||
{
|
||||
string message = String.Format(CultureReplacer.DefaultCulture,
|
||||
"The value of argument '{0}' ({1}) is invalid for Enum type '{2}'.{3}Parameter name: {0}",
|
||||
paramName, invalidValue, enumType.Name, Environment.NewLine);
|
||||
"The value of argument '{0}' ({1}) is invalid for Enum type '{2}'.{3}",
|
||||
paramName, invalidValue, enumType.Name, GetParameterMessage(paramName));
|
||||
|
||||
#if NETFX_CORE // InvalidEnumArgumentException not available in netstandard1.3.
|
||||
return Throws<Error.InvalidEnumArgumentException>(testCode, message, allowDerivedExceptions);
|
||||
|
@ -581,6 +581,15 @@ namespace Microsoft.TestCommon
|
|||
return ex;
|
||||
}
|
||||
|
||||
private static string GetParameterMessage(string parameterName)
|
||||
{
|
||||
#if NETCOREAPP3_1_OR_GREATER
|
||||
return " (Parameter '" + parameterName + "')";
|
||||
#else
|
||||
return Environment.NewLine + "Parameter name: " + parameterName;
|
||||
#endif
|
||||
}
|
||||
|
||||
// We've re-implemented all the xUnit.net Throws code so that we can get this
|
||||
// updated implementation of RecordException which silently unwraps any instances
|
||||
// of AggregateException. In addition to unwrapping exceptions, this method ensures
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks>net462;netcoreapp2.1;net6.0</TargetFrameworks>
|
||||
<Configurations>$(Configurations);CodeAnalysis</Configurations>
|
||||
<DefineConstants
|
||||
Condition=" '$(NetFX_Core)' == 'true' ">$(DefineConstants);NETFX_CORE</DefineConstants>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.1;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net462;netcoreapp2.1;net6.0</TargetFrameworks>
|
||||
<RootNamespace>System.Net.Http</RootNamespace>
|
||||
<OutputPath>..\..\bin\$(Configuration)\Test\NetCore\</OutputPath>
|
||||
<Configurations>$(Configurations);CodeAnalysis</Configurations>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.1;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net462;netcoreapp2.1;net6.0</TargetFrameworks>
|
||||
<RootNamespace>System.Net.Http</RootNamespace>
|
||||
<OutputPath>..\..\bin\$(Configuration)\Test\NetStandard\</OutputPath>
|
||||
<Configurations>$(Configurations);CodeAnalysis</Configurations>
|
||||
|
|
|
@ -330,7 +330,12 @@ namespace System.Net.Http.Formatting
|
|||
// Act & Assert
|
||||
await Assert.ThrowsAsync<JsonReaderException>(
|
||||
() => formatter.ReadFromStreamAsync(variationType, stream, content, null),
|
||||
"Could not convert to decimal: 7.92281625142643E+28. Path 'Value'.");
|
||||
#if NETCOREAPP3_1_OR_GREATER
|
||||
"Could not convert to decimal: 7.922816251426434E+28. Path 'Value'."
|
||||
#else
|
||||
"Could not convert to decimal: 7.92281625142643E+28. Path 'Value'."
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -11,6 +11,7 @@ using System.Runtime.Serialization.Json;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.TestCommon;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
@ -576,6 +577,29 @@ namespace System.Net.Http.Formatting
|
|||
formatter, content, formattedContent, mediaType, encoding, isDefaultEncoding);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
// Cannot Mock a Stream and let JsonWriter write to it. Writer will use ReadOnlySpan in this case and such
|
||||
// parameters are not currently mockable. See moq/moq4#829, moq/moq4#979, and dotnet/runtime#45152.
|
||||
// Override here avoids the Mock<Stream> and should confirm this Stream is not closed. Also adds an
|
||||
// additional check of the written text.
|
||||
[Fact]
|
||||
public override async Task WriteToStreamAsync_WhenObjectIsNull_WritesDataButDoesNotCloseStream()
|
||||
{
|
||||
// Arrange
|
||||
JsonMediaTypeFormatter formatter = CreateFormatter();
|
||||
Stream stream = new MemoryStream();
|
||||
HttpContent content = new StringContent(String.Empty);
|
||||
|
||||
// Act
|
||||
await formatter.WriteToStreamAsync(typeof(SampleType), null, stream, content, null);
|
||||
|
||||
// Assert (stream will throw if it has been closed)
|
||||
stream.Position = 0;
|
||||
using var reader = new StreamReader(stream);
|
||||
Assert.Equal("null", reader.ReadToEnd());
|
||||
}
|
||||
#endif
|
||||
|
||||
public class TestJsonMediaTypeFormatter : JsonMediaTypeFormatter
|
||||
{
|
||||
public TestJsonMediaTypeFormatter()
|
||||
|
|
|
@ -56,8 +56,10 @@ namespace System.Net.Http.Handlers
|
|||
}
|
||||
|
||||
[Theory]
|
||||
#if !NET6_0_OR_GREATER // https://github.com/aspnet/AspNetWebStack/issues/386
|
||||
[InlineData(false, false)]
|
||||
[InlineData(false, true)]
|
||||
#endif
|
||||
[InlineData(true, false)]
|
||||
[InlineData(true, true)]
|
||||
public async Task SendAsync_InsertsReceiveProgressWhenResponseEntityPresent(bool insertResponseEntity, bool addReceiveProgressHandler)
|
||||
|
|
|
@ -14,6 +14,12 @@ namespace System.Net.Http
|
|||
{
|
||||
public class HttpClientExtensionsTest
|
||||
{
|
||||
private const string InvalidUriMessage =
|
||||
#if NET6_0_OR_GREATER
|
||||
"An invalid request URI was provided. Either the request URI must be an absolute URI or BaseAddress must be set.";
|
||||
#else
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.";
|
||||
#endif
|
||||
private readonly MediaTypeFormatter _formatter = new MockMediaTypeFormatter { CallBase = true };
|
||||
private readonly HttpClient _client;
|
||||
private readonly MediaTypeHeaderValue _mediaTypeHeader = MediaTypeHeaderValue.Parse("foo/bar; charset=utf-16");
|
||||
|
@ -40,7 +46,7 @@ namespace System.Net.Http
|
|||
public void PostAsJsonAsync_String_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PostAsJsonAsync((string)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -64,7 +70,7 @@ namespace System.Net.Http
|
|||
public void PostAsXmlAsync_String_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PostAsXmlAsync((string)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -88,7 +94,7 @@ namespace System.Net.Http
|
|||
public void PostAsync_String_WhenRequestUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PostAsync((string)null, new object(), new JsonMediaTypeFormatter(), "text/json"),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -169,7 +175,7 @@ namespace System.Net.Http
|
|||
public void PutAsJsonAsync_String_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PutAsJsonAsync((string)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -193,7 +199,7 @@ namespace System.Net.Http
|
|||
public void PutAsXmlAsync_String_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PutAsXmlAsync((string)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -217,7 +223,7 @@ namespace System.Net.Http
|
|||
public void PutAsync_String_WhenRequestUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PutAsync((string)null, new object(), new JsonMediaTypeFormatter(), "text/json"),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -298,7 +304,7 @@ namespace System.Net.Http
|
|||
public void PostAsJsonAsync_Uri_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PostAsJsonAsync((Uri)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -322,7 +328,7 @@ namespace System.Net.Http
|
|||
public void PostAsXmlAsync_Uri_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PostAsXmlAsync((Uri)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -346,7 +352,7 @@ namespace System.Net.Http
|
|||
public void PostAsync_Uri_WhenRequestUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PostAsync((Uri)null, new object(), new JsonMediaTypeFormatter(), "text/json"),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -427,7 +433,7 @@ namespace System.Net.Http
|
|||
public void PutAsJsonAsync_Uri_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PutAsJsonAsync((Uri)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -451,7 +457,7 @@ namespace System.Net.Http
|
|||
public void PutAsXmlAsync_Uri_WhenUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PutAsXmlAsync((Uri)null, new object()),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -475,7 +481,7 @@ namespace System.Net.Http
|
|||
public void PutAsync_Uri_WhenRequestUriIsNull_ThrowsException()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => _client.PutAsync((Uri)null, new object(), new JsonMediaTypeFormatter(), "text/json"),
|
||||
"An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.");
|
||||
InvalidUriMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -164,6 +164,7 @@ namespace System.Net.Http
|
|||
}
|
||||
}
|
||||
|
||||
#if !NET6_0_OR_GREATER // https://github.com/aspnet/AspNetWebStack/issues/386
|
||||
[Fact]
|
||||
public async Task SerializeResponse()
|
||||
{
|
||||
|
@ -185,6 +186,7 @@ namespace System.Net.Http
|
|||
await ValidateResponse(instance, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public async Task SerializeRequestWithEntity()
|
||||
|
@ -241,6 +243,7 @@ namespace System.Net.Http
|
|||
}
|
||||
}
|
||||
|
||||
#if !NET6_0_OR_GREATER // https://github.com/aspnet/AspNetWebStack/issues/386
|
||||
[Fact]
|
||||
public async Task SerializeResponseAsync()
|
||||
{
|
||||
|
@ -251,6 +254,7 @@ namespace System.Net.Http
|
|||
await ValidateResponse(instance, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public async Task SerializeRequestWithPortAndQueryAsync()
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace System.Text.Tests
|
|||
|
||||
// Async
|
||||
|
||||
#if NETCOREAPP3_1 || NET5_0_OR_GREATER || NETSTANDARD2_1
|
||||
#if NETCOREAPP3_1_OR_GREATER || NETSTANDARD2_1
|
||||
innerStream = new MemoryStream();
|
||||
transcodingStream = new TranscodingStream(innerStream, Encoding.UTF8, Encoding.UTF8, leaveOpen: false);
|
||||
transcodingStream.DisposeAsync().GetAwaiter().GetResult();
|
||||
|
@ -196,7 +196,7 @@ namespace System.Text.Tests
|
|||
|
||||
// Async
|
||||
|
||||
#if NETCOREAPP3_1 || NET5_0_OR_GREATER || NETSTANDARD2_1
|
||||
#if NETCOREAPP3_1_OR_GREATER || NETSTANDARD2_1
|
||||
innerStream = new MemoryStream();
|
||||
transcodingStream = new TranscodingStream(innerStream, Encoding.UTF8, Encoding.UTF8, leaveOpen: true);
|
||||
transcodingStream.DisposeAsync().GetAwaiter().GetResult();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<Private>False</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче