Skip to content

Commit

Permalink
Merge pull request #23 from ppittle/single-assembly
Browse files Browse the repository at this point in the history
Single assembly
  • Loading branch information
ppittle authored Mar 22, 2018
2 parents 7ac8b2e + b72446a commit c4f1a32
Show file tree
Hide file tree
Showing 28 changed files with 434 additions and 276 deletions.
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ build:
verbosity: minimal
test_script:
- ps: >-
.\src\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -target:"xunit.console.clr4.exe" "-targetargs:""src\HttpWebRequestWrapper.Tests\bin\$env:CONFIGURATION\HttpWebRequestWrapper.Tests.dll"" /noshadow /appveyor" -filter:"+[HttpWebRequestWrapper*]*" -output:opencoverCoverage.xml -returntargetcode
.\src\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -target:"xunit.console.clr4.exe" "-targetargs:""src\HttpWebRequestWrapper.Tests\bin\$env:CONFIGURATION\HttpWebRequestWrapper.Tests.dll"" /noshadow /appveyor" -filter:"+[HttpWebRequestWrapper*]*" -output:opencoverCoverage.xml -returntargetcode
.\src\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -target:"xunit.console.clr4.exe" "-targetargs:""src\HttpWebRequestWrapper.Tests\bin\$env:CONFIGURATION\HttpWebRequestWrapper.Tests.35.dll"" /noshadow /appveyor" -filter:"+[HttpWebRequestWrapper*]*" -output:opencoverCoverage.xml -returntargetcode -mergeoutput
if ($LastExitCode -ne 0){
throw "xUnit failed with code $LastExitCode"
Expand Down

This file was deleted.

38 changes: 0 additions & 38 deletions src/HttpWebRequestWrapper.HttpClient/Properties/AssemblyInfo.cs

This file was deleted.

3 changes: 3 additions & 0 deletions src/HttpWebRequestWrapper.Tests/DelegateCreatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using Should;
using Xunit;

// Justification: Test class
// ReSharper disable ImplicitlyCapturedClosure

namespace HttpWebRequestWrapper.Tests
{
/// <summary>
Expand Down
58 changes: 29 additions & 29 deletions src/HttpWebRequestWrapper.Tests/HttpClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using HttpWebRequestWrapper.HttpClient;
using HttpWebRequestWrapper.Recording;
using Should;
using Xunit;

// Justification: Test class
// ReSharper disable InconsistentNaming
// ReSharper disable ConvertToConstant.Local

namespace HttpWebRequestWrapper.Tests
{
Expand All @@ -36,9 +36,9 @@ public async Task CanRecord()
HttpResponseMessage response;

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperRecorderCreator(recordingSession)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperRecorderCreator(recordingSession)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.GetAsync(url);
}
Expand All @@ -62,9 +62,9 @@ public async Task CanRecordWebRequestException()
HttpResponseMessage response;

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperRecorderCreator(recordingSession)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperRecorderCreator(recordingSession)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.GetAsync("https://accounts.google.com/o/oauth2/auth");
}
Expand Down Expand Up @@ -92,9 +92,9 @@ public async Task CanRecordPostWithRequestBody()
HttpResponseMessage response;

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperRecorderCreator(recordingSession)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperRecorderCreator(recordingSession)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.PostAsync(url, new StringContent(requestBody));
}
Expand Down Expand Up @@ -122,9 +122,9 @@ public async Task CanInterceptAndSpoofResponse()
HttpResponseMessage response;

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.GetAsync(new Uri("http://fakeSite.fake"));
}
Expand Down Expand Up @@ -159,10 +159,10 @@ public async Task CanInterceptPost()
HttpResponseMessage response;

// ACT
using (new HttpClientAndRequestWrapperSession(
using (new HttpWebRequestWrapperSession(
new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.PostAsync(requestUrl, new StringContent(requestBody));
}
Expand Down Expand Up @@ -193,9 +193,9 @@ public async Task CanInterceptWhenHttpClientUsesWebRequestHandler()
string response;

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
var httpClient = new System.Net.Http.HttpClient(new WebRequestHandler());
var httpClient = new HttpClient(new WebRequestHandler());

response = await httpClient.GetStringAsync(requestUrl);
}
Expand Down Expand Up @@ -226,9 +226,9 @@ public async Task CanInterceptWhenHttpClientSetsBaseAddress()
string response;

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
var httpClient = new System.Net.Http.HttpClient()
var httpClient = new HttpClient()
{
BaseAddress = requestBaseUrl
};
Expand Down Expand Up @@ -268,10 +268,10 @@ public async Task CanInterceptCustomRequestMessage()
HttpResponseMessage response;

// ACT
using (new HttpClientAndRequestWrapperSession(
using (new HttpWebRequestWrapperSession(
new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.SendAsync(requestMessage);
}
Expand Down Expand Up @@ -308,15 +308,15 @@ public async Task CanSupportMultipleConcurrentHttpClients()
throw new Exception($"Couldn't match url [{req.HttpWebRequest.RequestUri}]");
});

using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
// ACT
var sharedClient = new System.Net.Http.HttpClient();
var sharedClient = new HttpClient();

var task1 = sharedClient.GetStringAsync(url1);
var task2 = sharedClient.GetStringAsync(url2);
var task3 = new System.Net.Http.HttpClient().GetStringAsync(url3);
var task1b = new System.Net.Http.HttpClient().GetStringAsync(url1);
var task3 = new HttpClient().GetStringAsync(url3);
var task1b = new HttpClient().GetStringAsync(url1);

await Task.WhenAll(task1, task2, task3, task1b);

Expand All @@ -334,7 +334,7 @@ public async Task CanSupportMultipleConcurrentHttpClients()
/// <see cref="HttpClient.SendAsync(System.Net.Http.HttpRequestMessage)"/>,
/// a 3rd call would never return.
/// <para />
/// This test is *not* able to completly reproduce the bad behavior.
/// This test is *not* able to completely reproduce the bad behavior.
/// However, the solution was to add
/// an override for
/// <see cref="HttpWebRequestWrapperInterceptor.BeginGetRequestStream"/>.
Expand Down Expand Up @@ -362,7 +362,7 @@ public async Task CanInterceptMultipleSequentialPosts()
ResponseBody = new RecordedStream
{
SerializedStream = "Test Response",
// improtant - force gzip so a compression stream gets plumbed
// important - force gzip so a compression stream gets plumbed
// through the http client as that changes behavior
IsGzippedCompressed = true
}
Expand All @@ -374,20 +374,20 @@ public async Task CanInterceptMultipleSequentialPosts()
RecordedRequests = new List<RecordedRequest> {recordedRequest}
})
{
MatchingAlgorithm = (intercpeted, recorded) =>
MatchingAlgorithm = (intercepted, recorded) =>
string.Equals(
intercpeted.HttpWebRequest.RequestUri.ToString(),
intercepted.HttpWebRequest.RequestUri.ToString(),
recorded.Url,
StringComparison.OrdinalIgnoreCase)
};

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(requestBuilder)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(requestBuilder)))
{

for (var i = 0; i < numberOfSequentialRequests; i++)
{
var httpClient = new System.Net.Http.HttpClient(new WebRequestHandler());
var httpClient = new HttpClient(new WebRequestHandler());

var message = new HttpRequestMessage(HttpMethod.Post, recordedRequest.Url)
{
Expand Down Expand Up @@ -430,9 +430,9 @@ public async Task CanInterceptAndSpoofWebRequestException()
HttpResponseMessage response;

// ACT
using (new HttpClientAndRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.GetAsync(new Uri("http://fakeSite.fake"));
}
Expand Down
Loading

0 comments on commit c4f1a32

Please sign in to comment.