Skip to content

Commit d0953f4

Browse files
authored
update xunit versions (#3053)
* Update XUnit versions * Fix Xunit warnings
1 parent fcda0dc commit d0953f4

File tree

12 files changed

+62
-46
lines changed

12 files changed

+62
-46
lines changed

tests/Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<MicrosoftNetTestSdkVersion>17.4.0</MicrosoftNetTestSdkVersion>
1616
<!--GHSA-5crp-9r3c-p9vr-->
1717
<NewtonsoftJsonVersion>13.0.2</NewtonsoftJsonVersion>
18-
<XunitVersion>2.4.2</XunitVersion>
19-
<XunitRunnerVisualStudioVersion>2.4.5</XunitRunnerVisualStudioVersion>
20-
<XunitAssertVersion>2.4.2</XunitAssertVersion>
18+
<XunitVersion>2.9.2</XunitVersion>
19+
<XunitRunnerVisualStudioVersion>2.8.2</XunitRunnerVisualStudioVersion>
20+
<XunitAssertVersion>2.9.2</XunitAssertVersion>
2121
<XunitExtensibilityCoreVersion>2.4.2</XunitExtensibilityCoreVersion>
2222
<NSubstituteVersion>4.2.2</NSubstituteVersion>
2323
<NSubstituteAnalyzersCSharpVersion>1.0.13</NSubstituteAnalyzersCSharpVersion>

tests/E2E Tests/GraphServiceClientTests/GraphServiceClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public async Task AuthenticateRequestAsync_NonGraphUri_DoesNotSetAuthZHeader()
8181
GraphAuthenticationProvider graphAuthenticationProvider = new(_authorizationHeaderProvider, new GraphServiceClientOptions());
8282

8383
// act
84-
await graphAuthenticationProvider.AuthenticateRequestAsync(request).ConfigureAwait(false);
84+
await graphAuthenticationProvider.AuthenticateRequestAsync(request);
8585

8686
// assert
8787
Assert.False(request.Headers.ContainsKey("Authorization"));

tests/E2E Tests/WebAppUiTests/WebAppIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task ChallengeUser_MicrosoftIdentityFlow_RemoteApp_ValidEmailPasswo
2828
IBrowser browser = await playwright.Chromium.LaunchAsync(new() { Headless = true });
2929
IPage page = await browser.NewPageAsync();
3030
await page.GotoAsync(UrlString);
31-
LabResponse labResponse = await LabUserHelper.GetDefaultUserAsync().ConfigureAwait(false);
31+
LabResponse labResponse = await LabUserHelper.GetDefaultUserAsync();
3232

3333
try
3434
{

tests/Microsoft.Identity.Web.Test.Integration/AcquireTokenForAppIntegrationTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ public AcquireTokenForAppIntegrationTests(ITestOutputHelper output) // test set-
6767
[Theory]
6868
[InlineData(true, Constants.Bearer)]
6969
[InlineData(true, "PoP")]
70+
#pragma warning disable xUnit1012 // Null should only be used for nullable parameters
7071
[InlineData(false, null)]
72+
#pragma warning restore xUnit1012 // Null should only be used for nullable parameters
7173
public async Task GetAccessTokenOrAuthResultForApp_ReturnsAccessTokenOrAuthResultAsync(bool getAuthResult, string authHeaderPrefix)
7274
{
7375
// Arrange

tests/Microsoft.Identity.Web.Test/Certificates/DefaultCertificateLoaderTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public class DefaultCertificateLoaderTests
1616
// [InlineData(CertificateSource.Path, @"c:\temp\WebAppCallingWebApiCert.pfx", "")]
1717
// [InlineData(CertificateSource.StoreWithDistinguishedName, "CurrentUser/My", "CN=WebAppCallingWebApiCert")]
1818
// [InlineData(CertificateSource.StoreWithThumbprint, "CurrentUser/My", "962D129A859174EE8B5596985BD18EFEB6961684")]
19+
#pragma warning disable xUnit1012 // Null should only be used for nullable parameters
1920
[InlineData(CertificateSource.Base64Encoded, null, TestConstants.CertificateX5c)]
21+
#pragma warning restore xUnit1012 // Null should only be used for nullable parameters
2022
[Theory]
2123
public void TestDefaultCertificateLoader(CertificateSource certificateSource, string container, string referenceOrValue)
2224
{
@@ -53,7 +55,9 @@ public void TestDefaultCertificateLoader(CertificateSource certificateSource, st
5355
Assert.NotNull(certificateDescription.Certificate);
5456
}
5557

58+
#pragma warning disable xUnit1012 // Null should only be used for nullable parameters
5659
[InlineData(CertificateSource.Base64Encoded, null, TestConstants.CertificateX5c)]
60+
#pragma warning restore xUnit1012 // Null should only be used for nullable parameters
5761
[Theory]
5862
public void TestLoadFirstCertificate(
5963
CertificateSource certificateSource,
@@ -71,7 +75,9 @@ public void TestLoadFirstCertificate(
7175
Assert.Equal("CN=ACS2ClientCertificate", certificate.Issuer);
7276
}
7377

78+
#pragma warning disable xUnit1012 // Null should only be used for nullable parameters
7479
[InlineData(CertificateSource.Base64Encoded, null, TestConstants.CertificateX5c)]
80+
#pragma warning restore xUnit1012 // Null should only be used for nullable parameters
7581
[Theory]
7682
public void TestLoadAllCertificates(
7783
CertificateSource certificateSource,

tests/Microsoft.Identity.Web.Test/DownstreamWebApiSupport/DownstreamApiTests.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void SerializeInput_WithHttpContent_ReturnsSameContent()
119119
}
120120

121121
[Fact]
122-
public void SerializeInput_WithSerializer_ReturnsSerializedContent()
122+
public async Task SerializeInput_WithSerializer_ReturnsSerializedContentAsync()
123123
{
124124
// Arrange
125125
var input = new Person();
@@ -129,11 +129,12 @@ public void SerializeInput_WithSerializer_ReturnsSerializedContent()
129129
var result = DownstreamApi.SerializeInput(input, _options);
130130

131131
// Assert
132-
Assert.Equal("serialized", result?.ReadAsStringAsync().Result);
132+
Assert.NotNull(result);
133+
Assert.Equal("serialized", await result.ReadAsStringAsync());
133134
}
134135

135136
[Fact]
136-
public void SerializeInput_WithStringAndContentType_ReturnsStringContent()
137+
public async Task SerializeInput_WithStringAndContentType_ReturnsStringContent()
137138
{
138139
// Arrange
139140
var input = "test";
@@ -144,11 +145,11 @@ public void SerializeInput_WithStringAndContentType_ReturnsStringContent()
144145

145146
// Assert
146147
Assert.IsType<StringContent>(result);
147-
Assert.Equal(input, result.ReadAsStringAsync().Result);
148+
Assert.Equal(input, await result.ReadAsStringAsync());
148149
}
149150

150151
[Fact]
151-
public void SerializeInput_WithByteArray_ReturnsByteArrayContent()
152+
public async Task SerializeInput_WithByteArray_ReturnsByteArrayContentAsync()
152153
{
153154
// Arrange
154155
var input = new byte[] { 1, 2, 3 };
@@ -158,11 +159,11 @@ public void SerializeInput_WithByteArray_ReturnsByteArrayContent()
158159

159160
// Assert
160161
Assert.IsType<ByteArrayContent>(result);
161-
Assert.Equal(input, result.ReadAsByteArrayAsync().Result);
162+
Assert.Equal(input, await result.ReadAsByteArrayAsync());
162163
}
163164

164165
[Fact]
165-
public void SerializeInput_WithStream_ReturnsStreamContent()
166+
public async Task SerializeInput_WithStream_ReturnsStreamContentAsync()
166167
{
167168
// Arrange
168169
var input = new MemoryStream(Encoding.UTF8.GetBytes("test"));
@@ -172,7 +173,7 @@ public void SerializeInput_WithStream_ReturnsStreamContent()
172173

173174
// Assert
174175
Assert.IsType<StreamContent>(result);
175-
Assert.Equal("test", new StreamReader(result.ReadAsStreamAsync().Result).ReadToEnd());
176+
Assert.Equal("test", new StreamReader(await result.ReadAsStreamAsync()).ReadToEnd());
176177
}
177178

178179
[Fact]
@@ -279,7 +280,7 @@ public async Task DeserializeOutput_ReturnsDeserializedContent()
279280

280281
#if NET8_0_OR_GREATER
281282
[Fact]
282-
public void SerializeInput_WithSerializer_ReturnsSerializedContent_WhenJsonTypeInfoProvided()
283+
public async Task SerializeInput_WithSerializer_ReturnsSerializedContent_WhenJsonTypeInfoProvided()
283284
{
284285
// Arrange
285286
var input = new Person();
@@ -289,7 +290,8 @@ public void SerializeInput_WithSerializer_ReturnsSerializedContent_WhenJsonTypeI
289290
var result = DownstreamApi.SerializeInput(input, _options, CustomJsonContext.Default.Person);
290291

291292
// Assert
292-
Assert.Equal("serialized", result?.ReadAsStringAsync().Result);
293+
Assert.NotNull(result);
294+
Assert.Equal("serialized", await (result?.ReadAsStringAsync()));
293295
}
294296

295297
[Fact]

tests/Microsoft.Identity.Web.Test/MicrosoftIdentityOptionsTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void IsB2C_NullOrEmptyUserFlow_ReturnsFalse()
4848
Assert.False(options.IsB2C);
4949
}
5050

51+
#pragma warning disable xUnit1012 // Null should only be used for nullable parameters
5152
[Theory]
5253
[InlineData(TestConstants.ClientId, TestConstants.AadInstance, TestConstants.GuestTenantId, null, null, AzureAd, null)]
5354
[InlineData(null, TestConstants.AadInstance, TestConstants.GuestTenantId, null, null, null, AzureAd, MissingParam.ClientId)]
@@ -61,6 +62,7 @@ public void IsB2C_NullOrEmptyUserFlow_ReturnsFalse()
6162
[InlineData(TestConstants.ClientId, TestConstants.B2CInstance, null, null, TestConstants.B2CSignUpSignInUserFlow, "", AzureAdB2C, MissingParam.Domain)]
6263
[InlineData(TestConstants.ClientId, null, null, TestConstants.AuthorityWithTenantSpecified, null, null, AzureAd)]
6364
[InlineData(null, null, null, TestConstants.AuthorityWithTenantSpecified, null, null, AzureAd, MissingParam.ClientId)]
65+
#pragma warning restore xUnit1012 // Null should only be used for nullable parameters
6466
public void ValidateRequiredMicrosoftIdentityOptions(
6567
string clientId,
6668
string instance,

tests/Microsoft.Identity.Web.Test/Resource/JwtBearerMiddlewareDiagnosticsTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public JwtBearerMiddlewareDiagnosticsTests()
4646
}
4747

4848
[Fact]
49-
public async void Subscribe_OnAuthenticationFailed_CompletesSuccessfully()
49+
public async Task Subscribe_OnAuthenticationFailed_CompletesSuccessfully()
5050
{
5151
_jwtEvents.OnAuthenticationFailed = _eventHandler;
5252
_jwtDiagnostics.Subscribe(_jwtEvents);
@@ -56,7 +56,7 @@ public async void Subscribe_OnAuthenticationFailed_CompletesSuccessfully()
5656
}
5757

5858
[Fact]
59-
public async void Subscribe_OnMessageReceived_CompletesSuccessfully()
59+
public async Task Subscribe_OnMessageReceived_CompletesSuccessfully()
6060
{
6161
_jwtEvents.OnMessageReceived = _eventHandler;
6262
_jwtDiagnostics.Subscribe(_jwtEvents);
@@ -66,7 +66,7 @@ public async void Subscribe_OnMessageReceived_CompletesSuccessfully()
6666
}
6767

6868
[Fact]
69-
public async void Subscribe_OnTokenValidated_CompletesSuccessfully()
69+
public async Task Subscribe_OnTokenValidated_CompletesSuccessfully()
7070
{
7171
_jwtEvents.OnTokenValidated = _eventHandler;
7272
_jwtDiagnostics.Subscribe(_jwtEvents);
@@ -76,7 +76,7 @@ public async void Subscribe_OnTokenValidated_CompletesSuccessfully()
7676
}
7777

7878
[Fact]
79-
public async void Subscribe_OnChallenge_CompletesSuccessfully()
79+
public async Task Subscribe_OnChallenge_CompletesSuccessfully()
8080
{
8181
_jwtEvents.OnChallenge = _eventHandler;
8282
_jwtDiagnostics.Subscribe(_jwtEvents);
@@ -86,7 +86,7 @@ public async void Subscribe_OnChallenge_CompletesSuccessfully()
8686
}
8787

8888
[Fact]
89-
public async void Subscribe_OnAuthenticationFailedDefault_CompletesSuccessfully()
89+
public async Task Subscribe_OnAuthenticationFailedDefault_CompletesSuccessfully()
9090
{
9191
_jwtEvents = _jwtDiagnostics.Subscribe(null!);
9292
await _jwtEvents.AuthenticationFailed(new AuthenticationFailedContext(_httpContext, _authScheme, _jwtOptions));
@@ -95,7 +95,7 @@ public async void Subscribe_OnAuthenticationFailedDefault_CompletesSuccessfully(
9595
}
9696

9797
[Fact]
98-
public async void Subscribe_OnMessageReceivedDefault_CompletesSuccessfully()
98+
public async Task Subscribe_OnMessageReceivedDefault_CompletesSuccessfully()
9999
{
100100
_jwtEvents = _jwtDiagnostics.Subscribe(_jwtEvents);
101101
await _jwtEvents.MessageReceived(new MessageReceivedContext(_httpContext, _authScheme, _jwtOptions));
@@ -104,7 +104,7 @@ public async void Subscribe_OnMessageReceivedDefault_CompletesSuccessfully()
104104
}
105105

106106
[Fact]
107-
public async void Subscribe_OnTokenValidatedDefault_CompletesSuccessfully()
107+
public async Task Subscribe_OnTokenValidatedDefault_CompletesSuccessfully()
108108
{
109109
_jwtEvents = _jwtDiagnostics.Subscribe(_jwtEvents);
110110
await _jwtEvents.TokenValidated(new TokenValidatedContext(_httpContext, _authScheme, _jwtOptions));
@@ -113,7 +113,7 @@ public async void Subscribe_OnTokenValidatedDefault_CompletesSuccessfully()
113113
}
114114

115115
[Fact]
116-
public async void Subscribe_OnChallengeDefault_CompletesSuccessfully()
116+
public async Task Subscribe_OnChallengeDefault_CompletesSuccessfully()
117117
{
118118
_jwtEvents = _jwtDiagnostics.Subscribe(_jwtEvents);
119119
await _jwtEvents.Challenge(new JwtBearerChallengeContext(_httpContext, _authScheme, _jwtOptions, new AuthenticationProperties()));

tests/Microsoft.Identity.Web.Test/Resource/OpenIdConnectMiddlewareDiagnosticsTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public OpenIdConnectMiddlewareDiagnosticsTests()
4949
}
5050

5151
[Fact]
52-
public async void Subscribe_OnRedirectToIdentityProvider_CompletesSuccessfully()
52+
public async Task Subscribe_OnRedirectToIdentityProvider_CompletesSuccessfully()
5353
{
5454
_openIdEvents.OnRedirectToIdentityProvider = _eventHandler;
5555
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -59,7 +59,7 @@ public async void Subscribe_OnRedirectToIdentityProvider_CompletesSuccessfully()
5959
}
6060

6161
[Fact]
62-
public async void Subscribe_OnMessageReceived_CompletesSuccessfully()
62+
public async Task Subscribe_OnMessageReceived_CompletesSuccessfully()
6363
{
6464
_openIdEvents.OnMessageReceived = _eventHandler;
6565
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -69,7 +69,7 @@ public async void Subscribe_OnMessageReceived_CompletesSuccessfully()
6969
}
7070

7171
[Fact]
72-
public async void Subscribe_OnAuthorizationCodeReceived_CompletesSuccessfully()
72+
public async Task Subscribe_OnAuthorizationCodeReceived_CompletesSuccessfully()
7373
{
7474
_openIdEvents.OnAuthorizationCodeReceived = _eventHandler;
7575
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -79,7 +79,7 @@ public async void Subscribe_OnAuthorizationCodeReceived_CompletesSuccessfully()
7979
}
8080

8181
[Fact]
82-
public async void Subscribe_OnTokenResponseReceived_CompletesSuccessfully()
82+
public async Task Subscribe_OnTokenResponseReceived_CompletesSuccessfully()
8383
{
8484
_openIdEvents.OnTokenResponseReceived = _eventHandler;
8585
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -89,7 +89,7 @@ public async void Subscribe_OnTokenResponseReceived_CompletesSuccessfully()
8989
}
9090

9191
[Fact]
92-
public async void Subscribe_OnTokenValidated_CompletesSuccessfully()
92+
public async Task Subscribe_OnTokenValidated_CompletesSuccessfully()
9393
{
9494
_openIdEvents.OnTokenValidated = _eventHandler;
9595
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -99,7 +99,7 @@ public async void Subscribe_OnTokenValidated_CompletesSuccessfully()
9999
}
100100

101101
[Fact]
102-
public async void Subscribe_OnUserInformationReceived_CompletesSuccessfully()
102+
public async Task Subscribe_OnUserInformationReceived_CompletesSuccessfully()
103103
{
104104
_openIdEvents.OnUserInformationReceived = _eventHandler;
105105
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -109,7 +109,7 @@ public async void Subscribe_OnUserInformationReceived_CompletesSuccessfully()
109109
}
110110

111111
[Fact]
112-
public async void Subscribe_OnAuthenticationFailed_CompletesSuccessfully()
112+
public async Task Subscribe_OnAuthenticationFailed_CompletesSuccessfully()
113113
{
114114
_openIdEvents.OnAuthenticationFailed = _eventHandler;
115115
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -119,7 +119,7 @@ public async void Subscribe_OnAuthenticationFailed_CompletesSuccessfully()
119119
}
120120

121121
[Fact]
122-
public async void Subscribe_OnRemoteSignOut_CompletesSuccessfully()
122+
public async Task Subscribe_OnRemoteSignOut_CompletesSuccessfully()
123123
{
124124
_openIdEvents.OnRemoteSignOut = _eventHandler;
125125
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -129,7 +129,7 @@ public async void Subscribe_OnRemoteSignOut_CompletesSuccessfully()
129129
}
130130

131131
[Fact]
132-
public async void Subscribe_OnRedirectToIdentityProviderForSignOut_CompletesSuccessfully()
132+
public async Task Subscribe_OnRedirectToIdentityProviderForSignOut_CompletesSuccessfully()
133133
{
134134
_openIdEvents.OnRedirectToIdentityProviderForSignOut = _eventHandler;
135135
_openIdDiagnostics.Subscribe(_openIdEvents);
@@ -139,7 +139,7 @@ public async void Subscribe_OnRedirectToIdentityProviderForSignOut_CompletesSucc
139139
}
140140

141141
[Fact]
142-
public async void Subscribe_OnSignedOutCallbackRedirect_CompletesSuccessfully()
142+
public async Task Subscribe_OnSignedOutCallbackRedirect_CompletesSuccessfully()
143143
{
144144
_openIdEvents.OnSignedOutCallbackRedirect = _eventHandler;
145145
_openIdDiagnostics.Subscribe(_openIdEvents);

tests/Microsoft.Identity.Web.Test/Resource/RequiredScopeOrAppPermissionPolicyTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Security.Claims;
7+
using System.Threading.Tasks;
78
using Microsoft.AspNetCore.Authorization;
89
using Microsoft.Extensions.Configuration.Memory;
910
using Microsoft.Extensions.DependencyInjection;
@@ -31,7 +32,7 @@ public class RequiredScopeOrAppPermissionPolicyTests
3132
[InlineData(ClaimConstants.Roles)]
3233
[InlineData(ClaimConstants.Roles, true)]
3334
[RequiredScopeOrAppPermission(RequiredAppPermissionsConfigurationKey = "AzureAd:AppPermission")]
34-
public async void VerifyAppHasAnyAcceptedAppPermission_TestAsync(
35+
public async Task VerifyAppHasAnyAcceptedAppPermission_TestAsync(
3536
string claimType,
3637
bool withConfig = false)
3738
{
@@ -57,7 +58,7 @@ public async void VerifyAppHasAnyAcceptedAppPermission_TestAsync(
5758
[InlineData(ClaimConstants.Role, true)]
5859
[InlineData(ClaimConstants.Roles)]
5960
[InlineData(ClaimConstants.Roles, true)]
60-
public async void VerifyAppHasAnyAcceptedAppPermission_OneAppPermissionMatches_TestAsync(
61+
public async Task VerifyAppHasAnyAcceptedAppPermission_OneAppPermissionMatches_TestAsync(
6162
string claimType,
6263
bool withConfig = false)
6364
{
@@ -79,7 +80,7 @@ public async void VerifyAppHasAnyAcceptedAppPermission_OneAppPermissionMatches_T
7980
}
8081

8182
[Fact]
82-
public async void VerifyAppHasAnyAcceptedAppPermission_WithMismatchAppPermissionTest_FailsAsync()
83+
public async Task VerifyAppHasAnyAcceptedAppPermission_WithMismatchAppPermissionTest_FailsAsync()
8384
{
8485
// Arrange
8586
var authorizationService = BuildAuthorizationService(
@@ -98,7 +99,7 @@ public async void VerifyAppHasAnyAcceptedAppPermission_WithMismatchAppPermission
9899
}
99100

100101
[Fact]
101-
public async void VerifyAppHasAnyAcceptedAppPermission_RequiredAppPermissionMissingAsync()
102+
public async Task VerifyAppHasAnyAcceptedAppPermission_RequiredAppPermissionMissingAsync()
102103
{
103104
// Arrange
104105
var authorizationService = BuildAuthorizationService(
@@ -117,7 +118,7 @@ public async void VerifyAppHasAnyAcceptedAppPermission_RequiredAppPermissionMiss
117118
}
118119

119120
[Fact]
120-
public async void IncorrectPolicyName_FailsAsync()
121+
public async Task IncorrectPolicyName_FailsAsync()
121122
{
122123
// Arrange
123124
var authorizationService = BuildAuthorizationService(
@@ -134,7 +135,7 @@ public async void IncorrectPolicyName_FailsAsync()
134135
}
135136

136137
[Fact]
137-
public async void VerifyAppHasAnyAcceptedScopeOrAppPermission_TestAsync()
138+
public async Task VerifyAppHasAnyAcceptedScopeOrAppPermission_TestAsync()
138139
{
139140
// Arrange
140141
var authorizationService = BuildAuthorizationService(

0 commit comments

Comments
 (0)