Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #252 from microsoft/feature/code-cleanup
Browse files Browse the repository at this point in the history
feature/code cleanup
  • Loading branch information
baywet authored May 8, 2024
2 parents a1aa04c + 8e9013e commit 3e2d658
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
26 changes: 13 additions & 13 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"recommendations": [
"formulahendry.dotnet-test-explorer",
"ms-azure-devops.azure-pipelines",
"streetsidesoftware.code-spell-checker",
"editorconfig.editorconfig",
"donjayamanne.githistory",
"cschleiden.vscode-github-actions",
"github.copilot",
"github.vscode-pull-request-github",
"ms-vsliveshare.vsliveshare",
"esbenp.prettier-vscode"
]
}
"recommendations": [
"ms-azure-devops.azure-pipelines",
"streetsidesoftware.code-spell-checker",
"editorconfig.editorconfig",
"donjayamanne.githistory",
"cschleiden.vscode-github-actions",
"github.copilot",
"github.vscode-pull-request-github",
"ms-vsliveshare.vsliveshare",
"esbenp.prettier-vscode",
"ms-dotnettools.vscodeintellicode-csharp"
]
}
34 changes: 17 additions & 17 deletions Microsoft.Kiota.Http.HttpClientLibrary.Tests/RequestAdapterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public async Task GetRequestMessageFromRequestInformationSetsContentHeaders()
}

[Fact]
public async void SendMethodDoesNotThrowWithoutUrlTemplate()
public async Task SendMethodDoesNotThrowWithoutUrlTemplate()
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand Down Expand Up @@ -206,7 +206,7 @@ public async void SendMethodDoesNotThrowWithoutUrlTemplate()
[InlineData(HttpStatusCode.NonAuthoritativeInformation)]
[InlineData(HttpStatusCode.PartialContent)]
[Theory]
public async void SendStreamReturnsUsableStream(HttpStatusCode statusCode)
public async Task SendStreamReturnsUsableStream(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand Down Expand Up @@ -238,7 +238,7 @@ public async void SendStreamReturnsUsableStream(HttpStatusCode statusCode)
[InlineData(HttpStatusCode.NonAuthoritativeInformation)]
[InlineData(HttpStatusCode.NoContent)]
[Theory]
public async void SendStreamReturnsNullForNoContent(HttpStatusCode statusCode)
public async Task SendStreamReturnsNullForNoContent(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand Down Expand Up @@ -266,7 +266,7 @@ public async void SendStreamReturnsNullForNoContent(HttpStatusCode statusCode)
[InlineData(HttpStatusCode.NoContent)]
[InlineData(HttpStatusCode.PartialContent)]
[Theory]
public async void SendSNoContentDoesntFailOnOtherStatusCodes(HttpStatusCode statusCode)
public async Task SendSNoContentDoesntFailOnOtherStatusCodes(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand All @@ -292,7 +292,7 @@ public async void SendSNoContentDoesntFailOnOtherStatusCodes(HttpStatusCode stat
[InlineData(HttpStatusCode.NoContent)]
[InlineData(HttpStatusCode.ResetContent)]
[Theory]
public async void SendReturnsNullOnNoContent(HttpStatusCode statusCode)
public async Task SendReturnsNullOnNoContent(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand Down Expand Up @@ -321,7 +321,7 @@ public async void SendReturnsNullOnNoContent(HttpStatusCode statusCode)
[InlineData(HttpStatusCode.NoContent)]
[InlineData(HttpStatusCode.ResetContent)]
[Theory]
public async void SendReturnsNullOnNoContentWithContentHeaderPresent(HttpStatusCode statusCode)
public async Task SendReturnsNullOnNoContentWithContentHeaderPresent(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand All @@ -348,7 +348,7 @@ public async void SendReturnsNullOnNoContentWithContentHeaderPresent(HttpStatusC
[InlineData(HttpStatusCode.Accepted)]
[InlineData(HttpStatusCode.NonAuthoritativeInformation)]
[Theory]
public async void SendReturnsObjectOnContent(HttpStatusCode statusCode)
public async Task SendReturnsObjectOnContent(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand Down Expand Up @@ -379,7 +379,7 @@ public async void SendReturnsObjectOnContent(HttpStatusCode statusCode)
Assert.NotNull(response);
}
[Fact]
public async void RetriesOnCAEResponse()
public async Task RetriesOnCAEResponse()
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand All @@ -393,7 +393,7 @@ public async void RetriesOnCAEResponse()
StatusCode = methodCalled ? HttpStatusCode.OK : HttpStatusCode.Unauthorized,
Content = new StreamContent(new MemoryStream(Encoding.UTF8.GetBytes("Test")))
};
if(!methodCalled)
if (!methodCalled)
response.Headers.WwwAuthenticate.Add(new("Bearer", "realm=\"\", authorization_uri=\"https://login.microsoftonline.com/common/oauth2/authorize\", client_id=\"00000003-0000-0000-c000-000000000000\", error=\"insufficient_claims\", claims=\"eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTY1MjgxMzUwOCJ9fX0=\""));
methodCalled = true;
return Task.FromResult(response);
Expand All @@ -414,7 +414,7 @@ public async void RetriesOnCAEResponse()
[InlineData(HttpStatusCode.NotFound)]
[InlineData(HttpStatusCode.BadGateway)]
[Theory]
public async void SetsTheApiExceptionStatusCode(HttpStatusCode statusCode)
public async Task SetsTheApiExceptionStatusCode(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand All @@ -440,7 +440,7 @@ public async void SetsTheApiExceptionStatusCode(HttpStatusCode statusCode)
var response = await adapter.SendPrimitiveAsync<Stream>(requestInfo);
Assert.Fail("Expected an ApiException to be thrown");
}
catch(ApiException e)
catch (ApiException e)
{
Assert.Equal((int)statusCode, e.ResponseStatusCode);
Assert.True(e.ResponseHeaders.ContainsKey("request-id"));
Expand All @@ -449,7 +449,7 @@ public async void SetsTheApiExceptionStatusCode(HttpStatusCode statusCode)
[InlineData(HttpStatusCode.NotFound)]// 4XX
[InlineData(HttpStatusCode.BadGateway)]// 5XX
[Theory]
public async void SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusCode)
public async Task SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand All @@ -460,7 +460,7 @@ public async void SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusC
var responseMessage = new HttpResponseMessage
{
StatusCode = statusCode,
Content = new StringContent("{}",Encoding.UTF8,"application/json")
Content = new StringContent("{}", Encoding.UTF8, "application/json")
};
return responseMessage;
});
Expand All @@ -485,15 +485,15 @@ public async void SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusC
var response = await adapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping);
Assert.Fail("Expected an ApiException to be thrown");
}
catch(MockError mockError)
catch (MockError mockError)
{
Assert.Equal((int)statusCode, mockError.ResponseStatusCode);
Assert.Equal("A general error occured", mockError.Message);
}
}
[InlineData(HttpStatusCode.BadGateway)]// 5XX
[Theory]
public async void ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode)
public async Task ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode)
{
var mockHandler = new Mock<HttpMessageHandler>();
var client = new HttpClient(mockHandler.Object);
Expand All @@ -510,7 +510,7 @@ public async void ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode)
});
var mockParseNode = new Mock<IParseNode>();
mockParseNode.Setup<IParsable>(x => x.GetObjectValue(It.IsAny<ParsableFactory<IParsable>>()))
.Returns(new MockError("A general error occured: "+ statusCode.ToString()));
.Returns(new MockError("A general error occured: " + statusCode.ToString()));
var mockParseNodeFactory = new Mock<IParseNodeFactory>();
mockParseNodeFactory.Setup<IParseNode>(x => x.GetRootParseNode(It.IsAny<string>(), It.IsAny<Stream>()))
.Returns(mockParseNode.Object);
Expand All @@ -529,7 +529,7 @@ public async void ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode)
var response = await adapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping);
Assert.Fail("Expected an ApiException to be thrown");
}
catch(ApiException apiException)
catch (ApiException apiException)
{
Assert.Equal((int)statusCode, apiException.ResponseStatusCode);
Assert.Contains("The server returned an unexpected status code and no error factory is registered for this code", apiException.Message);
Expand Down

0 comments on commit 3e2d658

Please sign in to comment.