Skip to content

Commit 958a753

Browse files
authored
Merge pull request #909 from microsoftgraph/andrueastman/cleanup
chore: cleanup usage of obsolete members and async suffixes in test project
2 parents 6f090ad + b8f4209 commit 958a753

14 files changed

+101
-141
lines changed

tests/Microsoft.Graph.DotnetCore.Core.Test/Extensions/IDecryptableContentExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public IDecryptableContentExtensionsTests()
6464
}
6565

6666
[Fact]
67-
public async Task DecryptableContentCanBeDecryptedWithCertificate()
67+
public async Task DecryptableContentCanBeDecryptedWithCertificateAsync()
6868
{
6969
// Arrange
7070
var testChangeNotificationEncryptedContent = new TestChangeNotificationEncryptedContent

tests/Microsoft.Graph.DotnetCore.Core.Test/Microsoft.Graph.DotnetCore.Core.Test.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
66
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
77
<LangVersion>latest</LangVersion>
8-
<NoWarn>CS0618</NoWarn>
98
</PropertyGroup>
109
<ItemGroup>
1110
<None Update="xunit.runner.json">
@@ -35,6 +34,10 @@
3534
<PrivateAssets>all</PrivateAssets>
3635
</PackageReference>
3736
<ProjectReference Include="..\..\src\Microsoft.Graph.Core\Microsoft.Graph.Core.csproj" />
37+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20">
38+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
39+
<PrivateAssets>all</PrivateAssets>
40+
</PackageReference>
3841
</ItemGroup>
3942
<ItemGroup>
4043
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />

tests/Microsoft.Graph.DotnetCore.Core.Test/Mocks/MockCompressedContent.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/AsyncMonitorTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ public void Dispose()
5050
}
5151

5252
[Fact]
53-
public async Task PollForOperationCompletionAsync_IsCancelled()
53+
public async Task PollForOperationCompletionAsync_IsCancelledAsync()
5454
{
5555
var item = await this.asyncMonitor.PollForOperationCompletionAsync(this.progress.Object, new CancellationToken(true));
5656
Assert.Null(item);
5757
}
5858

5959
[Fact]
60-
public async Task PollForOperationCompletionAsync_OperationCompleted()
60+
public async Task PollForOperationCompletionAsync_OperationCompletedAsync()
6161
{
6262
bool called = false;
6363
this.progress.Setup(
@@ -96,7 +96,7 @@ public async Task PollForOperationCompletionAsync_OperationCompleted()
9696
}
9797

9898
[Fact]
99-
public async Task PollForOperationCompletionAsync_OperationCancelled()
99+
public async Task PollForOperationCompletionAsync_OperationCancelledAsync()
100100
{
101101
this.requestAdapter
102102
.Setup(requestAdapter => requestAdapter.SendNoContentAsync(It.IsAny<RequestInformation>(), It.IsAny<Dictionary<string, ParsableFactory<IParsable>>>(), It.IsAny<CancellationToken>()))
@@ -112,7 +112,7 @@ public async Task PollForOperationCompletionAsync_OperationCancelled()
112112
}
113113

114114
[Fact]
115-
public async Task PollForOperationCompletionAsync_OperationDeleteFailed()
115+
public async Task PollForOperationCompletionAsync_OperationDeleteFailedAsync()
116116
{
117117
this.requestAdapter
118118
.Setup(requestAdapter => requestAdapter.SendNoContentAsync(It.IsAny<RequestInformation>(), It.IsAny<Dictionary<string, ParsableFactory<IParsable>>>(), It.IsAny<CancellationToken>()))
@@ -128,7 +128,7 @@ public async Task PollForOperationCompletionAsync_OperationDeleteFailed()
128128
}
129129

130130
[Fact]
131-
public async Task PollForOperationCompletionAsync_OperationFailed()
131+
public async Task PollForOperationCompletionAsync_OperationFailedAsync()
132132
{
133133
this.requestAdapter
134134
.Setup(requestAdapter => requestAdapter.SendNoContentAsync(It.IsAny<RequestInformation>(), It.IsAny<Dictionary<string, ParsableFactory<IParsable>>>(), It.IsAny<CancellationToken>()))
@@ -144,7 +144,7 @@ public async Task PollForOperationCompletionAsync_OperationFailed()
144144
}
145145

146146
[Fact]
147-
public async Task PollForOperationCompletionAsync_OperationNull()
147+
public async Task PollForOperationCompletionAsync_OperationNullAsync()
148148
{
149149
this.requestAdapter
150150
.Setup(requestAdapter => requestAdapter.SendNoContentAsync(It.IsAny<RequestInformation>(), It.IsAny<Dictionary<string, ParsableFactory<IParsable>>>(), It.IsAny<CancellationToken>()))

tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/BatchRequestBuilderTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public async Task BatchRequestBuilderAsync()
3333
BatchRequestStep requestStep2 = new BatchRequestStep("2", httpRequestMessage2, new List<string> { "1" });
3434

3535
// 4.3 Add batch request steps to BatchRequestContent.
36+
#pragma warning disable CS0618 // Type or member is obsolete use the BatchRequestContentCollection for making batch requests
3637
BatchRequestContent batchRequestContent = new BatchRequestContent(baseClient, requestStep1, requestStep2);
38+
#pragma warning restore CS0618 // Type or member is obsolete use the BatchRequestContentCollection for making batch requests
3739
var requestInformation = await batchRequestBuilder.ToPostRequestInformationAsync(batchRequestContent);
3840

3941
// Assert

tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchRequestContentTests.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

5+
#pragma warning disable CS0618 // Type or member is obsolete Guidance is to use the BatchRequestContentCollection for making batch requests
56
namespace Microsoft.Graph.DotnetCore.Core.Test.Requests.Content
67
{
78
using System;
@@ -184,7 +185,7 @@ public void BatchRequestContent_RemoveBatchRequestStepWithIdForNonExistingId()
184185
}
185186

186187
[Fact]
187-
public async Task BatchRequestContent_NewBatchWithFailedRequests()
188+
public async Task BatchRequestContent_NewBatchWithFailedRequestsAsync()
188189
{
189190
BatchRequestContentCollection batchRequestContent = new BatchRequestContentCollection(client);
190191
var requestIds = new List<string>();
@@ -208,7 +209,7 @@ public async Task BatchRequestContent_NewBatchWithFailedRequests()
208209
}
209210

210211
[Fact]
211-
public async Task BatchRequestContent_NewBatchWithFailedRequests2()
212+
public async Task BatchRequestContent_NewBatchWithFailedRequests2Async()
212213
{
213214
BatchRequestContentCollection batchRequestContent = new BatchRequestContentCollection(client);
214215
var requestIds = new List<string>();
@@ -230,7 +231,7 @@ public async Task BatchRequestContent_NewBatchWithFailedRequests2()
230231
}
231232

232233
[Fact]
233-
public async Task BatchRequestContent_NewBatchWithFailedRequestsWithBody()
234+
public async Task BatchRequestContent_NewBatchWithFailedRequestsWithBodyAsync()
234235
{
235236
BatchRequestContentCollection batchRequestContent = new BatchRequestContentCollection(client);
236237
var requestIds = new List<string>();
@@ -311,7 +312,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
311312
}
312313

313314
[Fact]
314-
public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestContentSupportsNonJsonPayload()
315+
public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestContentSupportsNonJsonPayloadAsync()
315316
{
316317
using var fileStream = File.Open("ms-logo.png", FileMode.Open);
317318
BatchRequestStep batchRequestStep1 = new BatchRequestStep("1", new HttpRequestMessage(HttpMethod.Get, REQUEST_URL));
@@ -364,7 +365,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
364365
}
365366

366367
[Fact]
367-
public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestContentFromStepAsyncDoesNotModifyDateTimes()
368+
public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestContentFromStepAsyncDoesNotModifyDateTimesAsync()
368369
{
369370
// System.Text.Json is strict on json content by default. So make sure that there are no
370371
// trailing comma's and special characters
@@ -468,7 +469,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
468469
}
469470

470471
[Fact]
471-
public async Task BatchRequest_GetBathRequestContentAsyncRetainsInsertionOrder()
472+
public async Task BatchRequest_GetBathRequestContentAsyncRetainsInsertionOrderAsync()
472473
{
473474
BatchRequestStep batchRequestStep1 = new BatchRequestStep("1", new HttpRequestMessage(HttpMethod.Get, REQUEST_URL));
474475
BatchRequestStep batchRequestStep2 = new BatchRequestStep(Guid.NewGuid().ToString(), new HttpRequestMessage(HttpMethod.Get, REQUEST_URL), new List<string> { "1" });
@@ -537,7 +538,7 @@ public void BatchRequestContent_AddBatchRequestStepWithHttpRequestMessageToBatch
537538
}
538539

539540
[Fact]
540-
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequest()
541+
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestAsync()
541542
{
542543
// Arrange
543544
RequestInformation requestInformation = new RequestInformation() { HttpMethod = Method.GET, UrlTemplate = REQUEST_URL };
@@ -556,7 +557,7 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequest()
556557
}
557558

558559
[Fact]
559-
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestWithHeaderOptions()
560+
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestWithHeaderOptionsAsync()
560561
{
561562
// Create a BatchRequestContent from a BaseRequest object
562563
BatchRequestContent batchRequestContent = new BatchRequestContent(client);
@@ -593,7 +594,7 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestWithHead
593594
}
594595

595596
[Fact]
596-
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestToBatchRequestContentWithMaxSteps()
597+
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestToBatchRequestContentWithMaxStepsAsync()
597598
{
598599
// Arrange
599600
BatchRequestContent batchRequestContent = new BatchRequestContent(client);
@@ -623,7 +624,7 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestToBatchR
623624
[InlineData("https://graph.microsoft.com/beta/users/abcbeta123@wonderemail.com/events", "/users/abcbeta123@wonderemail.com/events")]
624625
[InlineData("https://graph.microsoft.com/v1.0/users?$filter=identities/any(id:id/issuer%20eq%20'$74707853-18b3-411f-ad57-2ef65f6fdeb0'%20and%20id/issuerAssignedId%20eq%20'**bobbetancourt@fakeemail.com**')", "/users?$filter=identities/any(id:id/issuer eq '$74707853-18b3-411f-ad57-2ef65f6fdeb0' and id/issuerAssignedId eq '**bobbetancourt@fakeemail.com**')")]
625626
[InlineData("https://graph.microsoft.com/beta/users?$filter=identities/any(id:id/issuer%20eq%20'$74707853-18b3-411f-ad57-2ef65f6fdeb0'%20and%20id/issuerAssignedId%20eq%20'**bobbetancourt@fakeemail.com**')&$top=1", "/users?$filter=identities/any(id:id/issuer eq '$74707853-18b3-411f-ad57-2ef65f6fdeb0' and id/issuerAssignedId eq '**bobbetancourt@fakeemail.com**')&$top=1")]
626-
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestProperlySetsVersion(string requestUrl, string expectedUrl)
627+
public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestProperlySetsVersionAsync(string requestUrl, string expectedUrl)
627628
{
628629
// Arrange
629630
BatchRequestStep batchRequestStep = new BatchRequestStep("1", new HttpRequestMessage(HttpMethod.Get, requestUrl));
@@ -647,7 +648,7 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestProperly
647648

648649
[Theory]
649650
[InlineData("https://graph.microsoft.com/v1.0/drives/b%21ynG/items/74707853-18b3-411f-ad57-2ef65f6fdeb0:/test.txt:/textfilecontentbytes", "/drives/b!ynG/items/74707853-18b3-411f-ad57-2ef65f6fdeb0:/test.txt:/textfilecontentbytes")]
650-
public async Task BatchRequestContent_AddBatchRequestPutStepWithBaseRequestProperlyEncodedURI(string requestUrl, string expectedUrl)
651+
public async Task BatchRequestContent_AddBatchRequestPutStepWithBaseRequestProperlyEncodedURIAsync(string requestUrl, string expectedUrl)
651652
{
652653
// Arrange
653654
BatchRequestStep batchRequestStep = new BatchRequestStep("1", new HttpRequestMessage(HttpMethod.Put, requestUrl));

tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Content/BatchResponseContentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public async Task BatchResponseContent_GetResponseStreamByIdAsync()
229229

230230

231231
[Fact]
232-
public async Task BatchResponseContent_GetResponseByIdAsyncWithDeseirializer()
232+
public async Task BatchResponseContent_GetResponseByIdAsyncWithDeseirializerAsync()
233233
{
234234
// Arrange
235235
string responseJSON = "{\"responses\":"
@@ -295,7 +295,7 @@ public async Task BatchResponseContent_GetResponseByIdAsyncWithDeseirializer()
295295
}
296296

297297
[Fact]
298-
public async Task BatchResponseContent_GetResponseByIdAsyncWithDeserializerWorksWithDateTimeOffsets()
298+
public async Task BatchResponseContent_GetResponseByIdAsyncWithDeserializerWorksWithDateTimeOffsetsAsync()
299299
{
300300
// Arrange an example Event object with a few properties
301301
string responseJSON = "\n{\n" +

tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/GraphClientFactoryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public void CreateClient_WithHandlers()
198198
}
199199

200200
[Fact]
201-
public async Task SendRequest_Redirect()
201+
public async Task SendRequest_RedirectAsync()
202202
{
203203
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "http://example.org/foo");
204204
var redirectResponse = new HttpResponseMessage(HttpStatusCode.MovedPermanently);
@@ -218,7 +218,7 @@ public async Task SendRequest_Redirect()
218218
}
219219

220220
[Fact]
221-
public async Task SendRequest_Retry()
221+
public async Task SendRequest_RetryAsync()
222222
{
223223
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "http://example.org/foo");
224224
httpRequestMessage.Content = new StringContent("Hello World");

tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/Middleware/TelemetryHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public TelemetryHandlerTests()
2424
}
2525

2626
[Fact]
27-
public async Task TelemetryHandlerShouldSetTelemetryHeaderWithDefaults()
27+
public async Task TelemetryHandlerShouldSetTelemetryHeaderWithDefaultsAsync()
2828
{
2929
var configuredTelemetryHandler = new GraphTelemetryHandler();
3030
configuredTelemetryHandler.InnerHandler = new FakeSuccessHandler();
@@ -56,7 +56,7 @@ public async Task TelemetryHandlerShouldSetTelemetryHeaderWithDefaults()
5656
}
5757

5858
[Fact]
59-
public async Task TelemetryHandlerShouldSetTelemetryHeaderWithCustomConfiguration()
59+
public async Task TelemetryHandlerShouldSetTelemetryHeaderWithCustomConfigurationAsync()
6060
{
6161
var clientOptions = new GraphClientOptions
6262
{

0 commit comments

Comments
 (0)