Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e7b6860

Browse files
dotnet-botdavidsh
authored andcommitted
Refactor Http tests for multiple test projects
This change sets up the layout for having multiple test projects for Http. It follows the current guidlines as well as working within the BUILDTOOLS requirements of having ".Tests.csproj" for the names of the projects.
1 parent 6a77a53 commit e7b6860

File tree

65 files changed

+2048
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2048
-83
lines changed

src/System.Net.Http/System.Net.Http.sln

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ VisualStudioVersion = 14.0.22816.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http", "src\System.Net.Http.csproj", "{1D422B1D-D7C4-41B9-862D-EB3D98DF37DE}"
66
EndProject
7-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Tests", "tests\System.Net.Http.Tests.csproj", "{5F9C3C9F-652E-461E-B2D6-85D264F5A733}"
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Unit.Tests", "tests\UnitTests\System.Net.Http.Unit.Tests.csproj", "{5F9C3C9F-652E-461E-B2D6-85D264F5A733}"
8+
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Tests", "tests\UnitTests\System.Net.Http.Tests.csproj", "{C85CF035-7804-41FF-9557-48B7C948B58D}"
810
EndProject
911
Global
1012
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -50,6 +52,22 @@ Global
5052
{5F9C3C9F-652E-461E-B2D6-85D264F5A733}.Windows_Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
5153
{5F9C3C9F-652E-461E-B2D6-85D264F5A733}.Windows_Release|Any CPU.ActiveCfg = Windows_Release|Any CPU
5254
{5F9C3C9F-652E-461E-B2D6-85D264F5A733}.Windows_Release|Any CPU.Build.0 = Windows_Release|Any CPU
55+
{C85CF035-7804-41FF-9557-48B7C948B58D}.FreeBSD_Debug|Any CPU.ActiveCfg = FreeBSD_Debug|Any CPU
56+
{C85CF035-7804-41FF-9557-48B7C948B58D}.FreeBSD_Debug|Any CPU.Build.0 = FreeBSD_Debug|Any CPU
57+
{C85CF035-7804-41FF-9557-48B7C948B58D}.FreeBSD_Release|Any CPU.ActiveCfg = FreeBSD_Release|Any CPU
58+
{C85CF035-7804-41FF-9557-48B7C948B58D}.FreeBSD_Release|Any CPU.Build.0 = FreeBSD_Release|Any CPU
59+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Linux_Debug|Any CPU.ActiveCfg = Linux_Debug|Any CPU
60+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Linux_Debug|Any CPU.Build.0 = Linux_Debug|Any CPU
61+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Linux_Release|Any CPU.ActiveCfg = Linux_Release|Any CPU
62+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Linux_Release|Any CPU.Build.0 = Linux_Release|Any CPU
63+
{C85CF035-7804-41FF-9557-48B7C948B58D}.OSX_Debug|Any CPU.ActiveCfg = OSX_Debug|Any CPU
64+
{C85CF035-7804-41FF-9557-48B7C948B58D}.OSX_Debug|Any CPU.Build.0 = OSX_Debug|Any CPU
65+
{C85CF035-7804-41FF-9557-48B7C948B58D}.OSX_Release|Any CPU.ActiveCfg = OSX_Release|Any CPU
66+
{C85CF035-7804-41FF-9557-48B7C948B58D}.OSX_Release|Any CPU.Build.0 = OSX_Release|Any CPU
67+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Windows_Debug|Any CPU.ActiveCfg = Windows_Debug|Any CPU
68+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Windows_Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
69+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Windows_Release|Any CPU.ActiveCfg = Windows_Release|Any CPU
70+
{C85CF035-7804-41FF-9557-48B7C948B58D}.Windows_Release|Any CPU.Build.0 = Windows_Release|Any CPU
5371
EndGlobalSection
5472
GlobalSection(SolutionProperties) = preSolution
5573
HideSolutionNode = FALSE
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Net;
6+
using System.Net.Http;
7+
8+
using Xunit;
9+
using Xunit.Abstractions;
10+
11+
namespace HttpTests
12+
{
13+
public class HttpClientHandlerTest
14+
{
15+
readonly ITestOutputHelper _output;
16+
17+
public HttpClientHandlerTest(ITestOutputHelper output)
18+
{
19+
_output = output;
20+
}
21+
22+
[Fact]
23+
public void SendAsync_SimpleGet_Success()
24+
{
25+
var handler = new HttpClientHandler();
26+
var client = new HttpClient(handler);
27+
28+
// TODO: This is a placeholder until GitHub Issue #2383 gets resolved.
29+
var response = client.GetAsync("http://httpbin.org").Result;
30+
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
31+
var responseContent = response.Content.ReadAsStringAsync().Result;
32+
_output.WriteLine(responseContent);
33+
}
34+
}
35+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{C85CF035-7804-41FF-9557-48B7C948B58D}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AssemblyName>System.Net.Http.Tests</AssemblyName>
10+
</PropertyGroup>
11+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
14+
</PropertyGroup>
15+
<ItemGroup>
16+
<Compile Include="HttpClientHandlerTest.cs" />
17+
<Compile Include="XunitTestAssemblyAtrributes.cs" />
18+
</ItemGroup>
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\src\System.Net.Http.csproj">
21+
<Project>{1D422B1D-D7C4-41B9-862D-EB3D98DF37DE}</Project>
22+
<Name>System.Net.Http</Name>
23+
</ProjectReference>
24+
</ItemGroup> <ItemGroup>
25+
<None Include="project.json" />
26+
</ItemGroup>
27+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
28+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
using Xunit;
7+
8+
// The WinHttpHandler unit tests need to have parallelism turned off between test classes since they rely on
9+
// a mock network with simulated failures controlled by singleton static classes (TestControl, TestServer).
10+
// This attribute will put all test classes into a single collection. Default Xunit behavior is to run tests
11+
// within a single collection in series and not in parallel.
12+
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"dependencies": {
3+
"Microsoft.Win32.Primitives": "4.0.0-*",
4+
"System.Globalization": "4.0.10-*",
5+
"System.IO": "4.0.10-*",
6+
"System.IO.Compression": "4.0.0-*",
7+
"System.Net.Primitives": "4.0.10-*",
8+
"System.Resources.ResourceManager": "4.0.0-*",
9+
"System.Runtime.Extensions": "4.0.10-*",
10+
"System.Runtime.Handles": "4.0.0-*",
11+
"System.Runtime.InteropServices": "4.0.20-*",
12+
"System.Security.Cryptography.X509Certificates": "4.0.0-*",
13+
"System.Security.Principal": "4.0.0-*",
14+
"System.Text.Encoding": "4.0.10-*",
15+
"System.Threading": "4.0.0-*",
16+
"System.Threading.Tasks": "4.0.0-*",
17+
"System.Threading.Thread": "4.0.0-*",
18+
"xunit": "2.0.0-beta5-build2785",
19+
"xunit.abstractions.netcore": "1.0.0-prerelease",
20+
"xunit.assert": "2.0.0-beta5-build2785",
21+
"xunit.core.netcore": "1.0.1-prerelease",
22+
"xunit.netcore.extensions": "1.0.0-prerelease-*"
23+
},
24+
"frameworks": {
25+
"dnxcore50": {}
26+
}
27+
}

0 commit comments

Comments
 (0)