Skip to content

Commit

Permalink
fixed resharper warnings and spelling mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
ppittle committed Mar 22, 2018
1 parent 22994bf commit b72446a
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 33 deletions.
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
26 changes: 13 additions & 13 deletions src/HttpWebRequestWrapper.Tests/HttpClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task CanRecord()
// ACT
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperRecorderCreator(recordingSession)))
{
var httpClient = new System.Net.Http.HttpClient();
var httpClient = new HttpClient();

response = await httpClient.GetAsync(url);
}
Expand All @@ -64,7 +64,7 @@ public async Task CanRecordWebRequestException()
// ACT
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 @@ -94,7 +94,7 @@ public async Task CanRecordPostWithRequestBody()
// ACT
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 @@ -124,7 +124,7 @@ public async Task CanInterceptAndSpoofResponse()
// ACT
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 @@ -162,7 +162,7 @@ public async Task CanInterceptPost()
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 @@ -195,7 +195,7 @@ public async Task CanInterceptWhenHttpClientUsesWebRequestHandler()
// ACT
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 @@ -228,7 +228,7 @@ public async Task CanInterceptWhenHttpClientSetsBaseAddress()
// ACT
using (new HttpWebRequestWrapperSession(new HttpWebRequestWrapperInterceptorCreator(responseCreator)))
{
var httpClient = new System.Net.Http.HttpClient()
var httpClient = new HttpClient()
{
BaseAddress = requestBaseUrl
};
Expand Down Expand Up @@ -271,7 +271,7 @@ public async Task CanInterceptCustomRequestMessage()
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 @@ -311,12 +311,12 @@ public async Task CanSupportMultipleConcurrentHttpClients()
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 Down Expand Up @@ -387,7 +387,7 @@ public async Task CanInterceptMultipleSequentialPosts()

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 @@ -432,7 +432,7 @@ public async Task CanInterceptAndSpoofWebRequestException()
// ACT
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
3 changes: 3 additions & 0 deletions src/HttpWebRequestWrapper.Tests/InterceptorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// ReSharper disable AssignNullToNotNullAttribute
// ReSharper disable ConvertToConstant.Local
// ReSharper disable ExpressionIsAlwaysNull
// ReSharper disable ArgumentsStyleLiteral
// ReSharper disable ArgumentsStyleStringLiteral
// ReSharper disable ArgumentsStyleNamedExpression

namespace HttpWebRequestWrapper.Tests
{
Expand Down
1 change: 1 addition & 0 deletions src/HttpWebRequestWrapper.Tests/RecorderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// ReSharper disable AssignNullToNotNullAttribute
// ReSharper disable PossibleNullReferenceException
// ReSharper disable ConvertToConstant.Local
// ReSharper disable ArgumentsStyleNamedExpression

namespace HttpWebRequestWrapper.Tests
{
Expand Down
10 changes: 7 additions & 3 deletions src/HttpWebRequestWrapper.Tests/Recording/RecordedStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
using Should;
using Xunit;

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

namespace HttpWebRequestWrapper.Tests.Recording
{
/// <summary>
Expand All @@ -24,7 +28,7 @@ public void ToStringReturnsStringContentWhenStreamIsEncoded()
Encoding.UTF8.GetBytes(content),
new HttpWebRequestWrapper(new Uri("http://fakeSite.fake"))
{
// set content type to force string conetent to be
// set content type to force string content to be
// encoded
ContentType = "image/png"
});
Expand Down Expand Up @@ -56,7 +60,7 @@ public void ToStringReturnsStringContentWhenStreamIsNotEncoded()
}

[Fact]
public void GZippedStreamIsStoredUncompresseed()
public void GZippedStreamIsStoredUncompressed()
{
// ARRANGE
var content = "Hello World";
Expand Down Expand Up @@ -118,7 +122,7 @@ public void DeflatedStreamIsStoredUncompressed()

// ASSERT
recordedStream.IsEncoded.ShouldBeFalse();
recordedStream.IsDefalteCompressed.ShouldBeTrue();
recordedStream.IsDeflateCompressed.ShouldBeTrue();

toString.ShouldEqual(content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public void CanPlaybackDeflatedResponse()
ResponseBody = new RecordedStream
{
SerializedStream = "Response 1",
IsDefalteCompressed = true
IsDeflateCompressed = true
},
ResponseHeaders = new RecordedHeaders
{
Expand Down Expand Up @@ -973,7 +973,7 @@ public void BuilderSetsWebExceptionWithResponse()
/// <see cref="WebExceptionStatus.ProtocolError"/>
/// </summary>
[Fact]
public void BuilderAlwaysSetsWebExcpetionResponseWhenStatusIsProtocolError()
public void BuilderAlwaysSetsWebExceptionResponseWhenStatusIsProtocolError()
{
// ARRANGE
var recordedRequest = new RecordedRequest
Expand All @@ -984,7 +984,7 @@ public void BuilderAlwaysSetsWebExcpetionResponseWhenStatusIsProtocolError()
{
Message = "Test Exception Message",
Type = typeof(WebException),
WebExceptionStatus = WebExceptionStatus.ProtocolError,
WebExceptionStatus = WebExceptionStatus.ProtocolError
},
ResponseHeaders = new RecordedHeaders
{
Expand Down
1 change: 1 addition & 0 deletions src/HttpWebRequestWrapper.Tests/SessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// Justification: Test Class
// ReSharper disable AssignNullToNotNullAttribute
// ReSharper disable ConvertToConstant.Local

namespace HttpWebRequestWrapper.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.IO;
using System.Net;
using HttpWebRequestWrapper.Recording;
// ReSharper disable ArgumentsStyleNamedExpression
// ReSharper disable ArgumentsStyleOther
// ReSharper disable ArgumentsStyleLiteral

namespace HttpWebRequestWrapper.Extensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/HttpWebRequestWrapper/HttpWebRequestWrapperRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void RecordResponse(HttpWebResponse response, RecordedRequest recordedRe

private static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[4096];
var buffer = new byte[4096];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
Expand Down
31 changes: 18 additions & 13 deletions src/HttpWebRequestWrapper/Recording/RecordedStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@
using System.Linq;
using System.Net;
using System.Text;
#if !NET40
using HttpWebRequestWrapper.Extensions;
#endif

// Justification: Can't use nameof in attriutes (ie DebuggerDisplay)
// Justification: Can't use nameof in attributes (ie DebuggerDisplay)
// ReSharper disable UseNameofExpression

// Justificaton: Public Api
// Justification: Public Api
// ReSharper disable MemberCanBePrivate.Global

// Justification: Prefer instance methods
// ReSharper disable MemberCanBeMadeStatic.Local

// Justification: Improves readability
// ReSharper disable ArgumentsStyleLiteral

namespace HttpWebRequestWrapper.Recording
{
/// <summary>
Expand Down Expand Up @@ -59,11 +64,11 @@ public class RecordedStream : IEquatable<RecordedStream>
/// be compressed with the Deflate aglorithm when
/// <see cref="ToStream"/> is called.
/// </summary>
public bool IsDefalteCompressed { get; set; }
public bool IsDeflateCompressed { get; set; }

/// <summary>
/// Creates an empty <see cref="RecordedStream"/>.
/// <see cref="SerializedStream"/> is intiailized to <see cref="string.Empty"/>
/// <see cref="SerializedStream"/> is initialized to <see cref="string.Empty"/>
/// </summary>
public RecordedStream()
{
Expand Down Expand Up @@ -182,7 +187,7 @@ private byte[] TryAndDeflateStream(byte[] streamBytes)
if (streamBytes.Length == 0)
return streamBytes;

// don't know of a way to pre-emptively guess if stream is compressed with deflate
// don't know of a way to preemptively guess if stream is compressed with deflate
// have to try to deflate in a try/catch
try
{
Expand All @@ -192,7 +197,7 @@ private byte[] TryAndDeflateStream(byte[] streamBytes)
{
deflateStream.CopyTo(decompressed);

IsDefalteCompressed = true;
IsDeflateCompressed = true;
return decompressed.ToArray();
}
}
Expand All @@ -205,7 +210,7 @@ private byte[] TryAndDeflateStream(byte[] streamBytes)
private bool ContentTypeIsForPlainText(string contentType)
{
return
// assume if contenttype are empty that
// assume if contentType are empty that
// we do **not** need to encode streamBytes
string.IsNullOrEmpty(contentType) ||
contentType.ToLower().Contains("text") ||
Expand All @@ -215,7 +220,7 @@ private bool ContentTypeIsForPlainText(string contentType)
}

/// <summary>
/// Builds a new <see cref="MemoryStream"/> correclty
/// Builds a new <see cref="MemoryStream"/> correctly
/// populated with the content of <see cref="SerializedStream"/>
/// </summary>
public Stream ToStream()
Expand All @@ -235,7 +240,7 @@ public Stream ToStream()
compressed.Seek(0, SeekOrigin.Begin);
return compressed;
}
else if (IsDefalteCompressed)
else if (IsDeflateCompressed)
{
var compressed = new MemoryStream();

Expand All @@ -257,12 +262,12 @@ public Stream ToStream()
/// <para />
/// Returns <see cref="SerializedStream"/> un-encoded and
/// un-compressed. If <see cref="SerializedStream"/> represents
/// binanry conent, this will not be useful. However, if for some
/// binary content, this will not be useful. However, if for some
/// reason <see cref="SerializedStream"/> is string content but has
/// been marked <see cref="IsEncoded"/>, this will return a usable string.
/// <para />
/// This is the perferred way of getting the Stream as a string. It
/// is unadvisable to inspect <see cref="SerializedStream"/> directly.
/// This is the preferred way of getting the Stream as a string. It
/// is inadvisable to inspect <see cref="SerializedStream"/> directly.
/// </summary>
/// <returns></returns>
public override string ToString()
Expand Down Expand Up @@ -295,7 +300,7 @@ public static implicit operator RecordedStream(string textResponse)
}

/// <summary>
/// Determines equality betweeen <paramref name="other"/> and this
/// Determines equality between <paramref name="other"/> and this
/// <see cref="RecordedStream"/>. This allows comparing <see cref="RecordedStream"/>s
/// easier for things like <see cref="RecordingSessionInterceptorRequestBuilder.MatchingAlgorithm"/>
/// as well as tests.
Expand Down

0 comments on commit b72446a

Please sign in to comment.