diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9a6a732..073fa2b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -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" - ] -} \ No newline at end of file + "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" + ] +} diff --git a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/RequestAdapterTests.cs b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/RequestAdapterTests.cs index 8ea1fbe..cd15006 100644 --- a/Microsoft.Kiota.Http.HttpClientLibrary.Tests/RequestAdapterTests.cs +++ b/Microsoft.Kiota.Http.HttpClientLibrary.Tests/RequestAdapterTests.cs @@ -176,7 +176,7 @@ public async Task GetRequestMessageFromRequestInformationSetsContentHeaders() } [Fact] - public async void SendMethodDoesNotThrowWithoutUrlTemplate() + public async Task SendMethodDoesNotThrowWithoutUrlTemplate() { var mockHandler = new Mock(); var client = new HttpClient(mockHandler.Object); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -440,7 +440,7 @@ public async void SetsTheApiExceptionStatusCode(HttpStatusCode statusCode) var response = await adapter.SendPrimitiveAsync(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")); @@ -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(); var client = new HttpClient(mockHandler.Object); @@ -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; }); @@ -485,7 +485,7 @@ public async void SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusC var response = await adapter.SendPrimitiveAsync(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); @@ -493,7 +493,7 @@ public async void SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusC } [InlineData(HttpStatusCode.BadGateway)]// 5XX [Theory] - public async void ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode) + public async Task ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode) { var mockHandler = new Mock(); var client = new HttpClient(mockHandler.Object); @@ -510,7 +510,7 @@ public async void ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode) }); var mockParseNode = new Mock(); mockParseNode.Setup(x => x.GetObjectValue(It.IsAny>())) - .Returns(new MockError("A general error occured: "+ statusCode.ToString())); + .Returns(new MockError("A general error occured: " + statusCode.ToString())); var mockParseNodeFactory = new Mock(); mockParseNodeFactory.Setup(x => x.GetRootParseNode(It.IsAny(), It.IsAny())) .Returns(mockParseNode.Object); @@ -529,7 +529,7 @@ public async void ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode) var response = await adapter.SendPrimitiveAsync(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);