Skip to content

Commit

Permalink
Clean-up and adjustments ✔️
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoDoyon committed Apr 30, 2021
1 parent 68213a5 commit 222debf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
22 changes: 5 additions & 17 deletions PactNet/Mocks/MockHttpService/AdminHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using PactNet.Mocks.MockHttpService.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
Expand All @@ -30,7 +29,7 @@ internal AdminHttpClient(
_jsonSerializerSettings = jsonSerializerSettings ?? JsonConfig.ApiSerializerSettings;
}

public AdminHttpClient(Uri baseUri) :
public AdminHttpClient(Uri baseUri) :
this(baseUri, new HttpClientHandler(), null)
{
}
Expand All @@ -42,13 +41,11 @@ public AdminHttpClient(Uri baseUri, JsonSerializerSettings jsonSerializerSetting

public async Task<string> SendAdminHttpRequest(HttpVerb method, string path, IDictionary<string, string> headers = null)
{
return await SendAdminHttpRequest<object>(method, path, null, headers:headers);
return await SendAdminHttpRequest<object>(method, path, null, headers: headers);
}

public async Task<string> SendAdminHttpRequest<T>(HttpVerb method, string path, T requestContent, IDictionary<string, string> headers = null) where T : class
{
var responseContent = Empty;

var request = new HttpRequestMessage(_httpMethodMapper.Convert(method), path);
request.Headers.Add(Constants.AdministrativeRequestHeaderKey, "true");

Expand All @@ -68,6 +65,7 @@ public async Task<string> SendAdminHttpRequest<T>(HttpVerb method, string path,

var response = await _httpClient.SendAsync(request, CancellationToken.None);
var responseStatusCode = response.StatusCode;
var responseContent = Empty;

if (response.Content != null)
{
Expand All @@ -82,22 +80,12 @@ public async Task<string> SendAdminHttpRequest<T>(HttpVerb method, string path,
throw new PactFailureException(responseContent);
}

if (!string.IsNullOrEmpty(responseContent))
{
return responseContent;
}
else
{
return string.Empty;
}
return !string.IsNullOrEmpty(responseContent) ? responseContent : Empty;
}

private void Dispose(IDisposable disposable)
{
if (disposable != null)
{
disposable.Dispose();
}
disposable?.Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"body": {
"eventId": "83f9262f-28f1-4703-ab1a-8cfd9e8249c9",
"eventType": "DetailsView",
"timestamp": "2021-04-28T13:52:20.7187546Z"
"timestamp": "2021-04-30T15:06:40.9990303Z"
},
"matchingRules": {
"$.headers.Server": {
Expand Down

0 comments on commit 222debf

Please sign in to comment.