Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Source/Mockolate/Web/HttpClientExtensions.Setup.Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static partial class HttpClientExtensions
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> DeleteAsync(
IParameter<string?>? requestUri)
IParameter<string?> requestUri)
=> setup.DeleteAsync(requestUri, It.IsAny<CancellationToken>());

/// <summary>
Expand All @@ -32,7 +32,7 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> DeleteAsync(
IParameter<Uri?>? requestUri)
IParameter<Uri?> requestUri)
=> setup.DeleteAsync(requestUri, It.IsAny<CancellationToken>());

/// <summary>
Expand All @@ -41,7 +41,7 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> DeleteAsync(
IParameter<string?>? requestUri,
IParameter<string?> requestUri,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -56,7 +56,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}

/// <summary>
Expand All @@ -65,7 +66,7 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> DeleteAsync(
IParameter<Uri?>? requestUri,
IParameter<Uri?> requestUri,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -80,7 +81,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions Source/Mockolate/Web/HttpClientExtensions.Setup.Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static partial class HttpClientExtensions
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> GetAsync(
IParameter<string?>? requestUri)
IParameter<string?> requestUri)
=> setup.GetAsync(requestUri, It.IsAny<CancellationToken>());

/// <summary>
Expand All @@ -32,7 +32,7 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> GetAsync(
IParameter<Uri?>? requestUri)
IParameter<Uri?> requestUri)
=> setup.GetAsync(requestUri, It.IsAny<CancellationToken>());

/// <summary>
Expand All @@ -41,7 +41,7 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> GetAsync(
IParameter<string?>? requestUri,
IParameter<string?> requestUri,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -56,7 +56,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}

/// <summary>
Expand All @@ -65,7 +66,7 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> GetAsync(
IParameter<Uri?>? requestUri,
IParameter<Uri?> requestUri,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -80,7 +81,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}
}
}
Expand Down
32 changes: 20 additions & 12 deletions Source/Mockolate/Web/HttpClientExtensions.Setup.Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,34 @@ public static partial class HttpClientExtensions
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PatchAsync(
IParameter<string?>? requestUri,
IParameter<HttpContent?>? content)
=> setup.PatchAsync(requestUri, content, It.IsAny<CancellationToken>());
IParameter<string?> requestUri,
IParameter<HttpContent?>? content = null)
=> setup.PatchAsync(
requestUri,
content ?? It.IsAny<HttpContent?>(),
It.IsAny<CancellationToken>());

/// <summary>
/// Setup for the method
/// <see cref="System.Net.Http.HttpClient.PatchAsync(Uri?, HttpContent?)" />
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PatchAsync(
IParameter<Uri?>? requestUri,
IParameter<HttpContent?>? content)
=> setup.PatchAsync(requestUri, content, It.IsAny<CancellationToken>());
IParameter<Uri?> requestUri,
IParameter<HttpContent?>? content = null)
=> setup.PatchAsync(
requestUri,
content ?? It.IsAny<HttpContent?>(),
It.IsAny<CancellationToken>());

/// <summary>
/// Setup for the method
/// <see cref="System.Net.Http.HttpClient.PatchAsync(string?, HttpContent?, System.Threading.CancellationToken)" />
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PatchAsync(
IParameter<string?>? requestUri,
IParameter<HttpContent?>? content,
IParameter<string?> requestUri,
IParameter<HttpContent?> content,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -61,7 +67,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}

/// <summary>
Expand All @@ -70,8 +77,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PatchAsync(
IParameter<Uri?>? requestUri,
IParameter<HttpContent?>? content,
IParameter<Uri?> requestUri,
IParameter<HttpContent?> content,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -87,7 +94,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}
}
}
Expand Down
32 changes: 20 additions & 12 deletions Source/Mockolate/Web/HttpClientExtensions.Setup.Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,34 @@ public static partial class HttpClientExtensions
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PostAsync(
IParameter<string?>? requestUri,
IParameter<HttpContent?>? content)
=> setup.PostAsync(requestUri, content, It.IsAny<CancellationToken>());
IParameter<string?> requestUri,
IParameter<HttpContent?>? content = null)
=> setup.PostAsync(
requestUri,
content ?? It.IsAny<HttpContent?>(),
It.IsAny<CancellationToken>());

/// <summary>
/// Setup for the method
/// <see cref="System.Net.Http.HttpClient.PostAsync(Uri?, HttpContent?)" />
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PostAsync(
IParameter<Uri?>? requestUri,
IParameter<HttpContent?>? content)
=> setup.PostAsync(requestUri, content, It.IsAny<CancellationToken>());
IParameter<Uri?> requestUri,
IParameter<HttpContent?>? content = null)
=> setup.PostAsync(
requestUri,
content ?? It.IsAny<HttpContent?>(),
It.IsAny<CancellationToken>());

/// <summary>
/// Setup for the method
/// <see cref="System.Net.Http.HttpClient.PostAsync(string?, HttpContent?, System.Threading.CancellationToken)" />
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PostAsync(
IParameter<string?>? requestUri,
IParameter<HttpContent?>? content,
IParameter<string?> requestUri,
IParameter<HttpContent?> content,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -60,7 +66,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}

/// <summary>
Expand All @@ -69,8 +76,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PostAsync(
IParameter<Uri?>? requestUri,
IParameter<HttpContent?>? content,
IParameter<Uri?> requestUri,
IParameter<HttpContent?> content,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -86,7 +93,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}
}
}
Expand Down
32 changes: 20 additions & 12 deletions Source/Mockolate/Web/HttpClientExtensions.Setup.Put.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,34 @@ public static partial class HttpClientExtensions
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PutAsync(
IParameter<string?>? requestUri,
IParameter<HttpContent?>? content)
=> setup.PutAsync(requestUri, content, It.IsAny<CancellationToken>());
IParameter<string?> requestUri,
IParameter<HttpContent?>? content = null)
=> setup.PutAsync(
requestUri,
content ?? It.IsAny<HttpContent?>(),
It.IsAny<CancellationToken>());

/// <summary>
/// Setup for the method
/// <see cref="System.Net.Http.HttpClient.PutAsync(Uri?, HttpContent?)" />
/// with the given <paramref name="requestUri" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PutAsync(
IParameter<Uri?>? requestUri,
IParameter<HttpContent?>? content)
=> setup.PutAsync(requestUri, content, It.IsAny<CancellationToken>());
IParameter<Uri?> requestUri,
IParameter<HttpContent?>? content = null)
=> setup.PutAsync(
requestUri,
content ?? It.IsAny<HttpContent?>(),
It.IsAny<CancellationToken>());

/// <summary>
/// Setup for the method
/// <see cref="System.Net.Http.HttpClient.PutAsync(string?, HttpContent?, System.Threading.CancellationToken)" />
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PutAsync(
IParameter<string?>? requestUri,
IParameter<HttpContent?>? content,
IParameter<string?> requestUri,
IParameter<HttpContent?> content,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -60,7 +66,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}

/// <summary>
Expand All @@ -69,8 +76,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, CancellationToken> PutAsync(
IParameter<Uri?>? requestUri,
IParameter<HttpContent?>? content,
IParameter<Uri?> requestUri,
IParameter<HttpContent?> content,
IParameter<CancellationToken> cancellationToken)
{
if (setup is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -86,7 +93,8 @@ public IReturnMethodSetup<Task<HttpResponseMessage>, HttpRequestMessage, Cancell
return methodSetup;
}

throw new MockException("Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot setup HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions Source/Mockolate/Web/HttpClientExtensions.Verify.Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static partial class HttpClientExtensions
/// with the given <paramref name="requestUri" />.
/// </summary>
public VerificationResult<HttpClient> DeleteAsync(
IParameter<string?>? requestUri)
IParameter<string?> requestUri)
=> verifyInvoked.DeleteAsync(requestUri, It.IsAny<CancellationToken>());

/// <summary>
Expand All @@ -31,7 +31,7 @@ public VerificationResult<HttpClient> DeleteAsync(
/// with the given <paramref name="requestUri" />.
/// </summary>
public VerificationResult<HttpClient> DeleteAsync(
IParameter<Uri?>? requestUri)
IParameter<Uri?> requestUri)
=> verifyInvoked.DeleteAsync(requestUri, It.IsAny<CancellationToken>());

/// <summary>
Expand All @@ -40,7 +40,7 @@ public VerificationResult<HttpClient> DeleteAsync(
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public VerificationResult<HttpClient> DeleteAsync(
IParameter<string?>? requestUri,
IParameter<string?> requestUri,
IParameter<CancellationToken> cancellationToken)
{
if (verifyInvoked is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -53,7 +53,8 @@ public VerificationResult<HttpClient> DeleteAsync(
.Map(httpClientMock.Subject);
}

throw new MockException("Cannot verify HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot verify HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}

/// <summary>
Expand All @@ -62,7 +63,7 @@ public VerificationResult<HttpClient> DeleteAsync(
/// with the given <paramref name="requestUri" /> and <paramref name="cancellationToken" />.
/// </summary>
public VerificationResult<HttpClient> DeleteAsync(
IParameter<Uri?>? requestUri,
IParameter<Uri?> requestUri,
IParameter<CancellationToken> cancellationToken)
{
if (verifyInvoked is Mock<HttpClient> { ConstructorParameters.Length: > 0, } httpClientMock &&
Expand All @@ -75,7 +76,8 @@ public VerificationResult<HttpClient> DeleteAsync(
.Map(httpClientMock.Subject);
}

throw new MockException("Cannot verify HttpClient when it is not mocked with a mockable HttpMessageHandler.");
throw new MockException(
"Cannot verify HttpClient when it is not mocked with a mockable HttpMessageHandler.");
}
}
}
Expand Down
Loading
Loading