From ff0958ea67be3941f366b36cbf141b64e55d7a5b Mon Sep 17 00:00:00 2001
From: Johann <10048453+johanndev@users.noreply.github.com>
Date: Thu, 8 Oct 2020 16:47:40 +0200
Subject: [PATCH] Enable nullable reference types support in the
unit/integration tests projects
---
.../OpenIddict.Abstractions.Tests.csproj | 1 +
.../OpenIddictBuilderTests.cs | 2 +-
.../OpenIddictExtensionsTests.cs | 4 +-
.../Primitives/OpenIddictConverterTests.cs | 32 ++--
.../Primitives/OpenIddictExtensionsTests.cs | 144 +++++++++---------
.../Primitives/OpenIddictMessageTests.cs | 20 +--
.../Primitives/OpenIddictParameterTests.cs | 90 +++++------
.../Primitives/OpenIddictRequestTests.cs | 5 +-
.../Primitives/OpenIddictResponseTests.cs | 5 +-
.../OpenIddict.Core.Tests.csproj | 1 +
.../OpenIddictCoreBuilderTests.cs | 10 +-
.../OpenIddictCoreExtensionsTests.cs | 4 +-
.../OpenIddict.EntityFramework.Tests.csproj | 1 +
.../OpenIddictEntityFrameworkBuilderTests.cs | 4 +-
...penIddictEntityFrameworkExtensionsTests.cs | 4 +-
...penIddict.EntityFrameworkCore.Tests.csproj | 1 +
...enIddictEntityFrameworkCoreBuilderTests.cs | 4 +-
...ddictEntityFrameworkCoreExtensionsTests.cs | 4 +-
.../OpenIddict.MongoDb.Tests.csproj | 1 +
.../OpenIddictMongoDbBuilderTests.cs | 4 +-
.../OpenIddictMongoDbExtensionsTests.cs | 4 +-
....Server.AspNetCore.IntegrationTests.csproj | 1 +
...ctServerAspNetCoreIntegrationTestServer.cs | 18 +--
...rverAspNetCoreIntegrationTests.Exchange.cs | 5 +-
...spNetCoreIntegrationTests.Introspection.cs | 2 +-
...erAspNetCoreIntegrationTests.Revocation.cs | 2 +-
...nIddictServerAspNetCoreIntegrationTests.cs | 24 +--
.../OpenIddict.Server.IntegrationTests.csproj | 1 +
.../OpenIddictServerIntegrationTestClient.cs | 20 +--
...ctServerIntegrationTests.Authentication.cs | 20 +--
...nIddictServerIntegrationTests.Discovery.cs | 128 ++++++++--------
...enIddictServerIntegrationTests.Exchange.cs | 18 +--
...ictServerIntegrationTests.Introspection.cs | 44 +++---
...IddictServerIntegrationTests.Revocation.cs | 22 +--
...penIddictServerIntegrationTests.Session.cs | 20 +--
...enIddictServerIntegrationTests.Userinfo.cs | 40 ++---
.../OpenIddictServerIntegrationTests.cs | 98 ++++++------
...Iddict.Server.Owin.IntegrationTests.csproj | 1 +
...dictServerOwinIntegrationTests.Exchange.cs | 2 +-
...erverOwinIntegrationTests.Introspection.cs | 2 +-
...ctServerOwinIntegrationTests.Revocation.cs | 2 +-
.../OpenIddictServerOwinIntegrationTests.cs | 8 +-
.../OpenIddict.Server.Tests.csproj | 1 +
.../OpenIddictServerBuilderTests.cs | 66 ++++----
44 files changed, 451 insertions(+), 439 deletions(-)
diff --git a/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj b/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj
index d9512dcd..42e3007f 100644
--- a/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj
+++ b/test/OpenIddict.Abstractions.Tests/OpenIddict.Abstractions.Tests.csproj
@@ -2,6 +2,7 @@
net461;netcoreapp2.1;netcoreapp3.1
+ enable
diff --git a/test/OpenIddict.Abstractions.Tests/OpenIddictBuilderTests.cs b/test/OpenIddict.Abstractions.Tests/OpenIddictBuilderTests.cs
index 747aabf5..6b85cfea 100644
--- a/test/OpenIddict.Abstractions.Tests/OpenIddictBuilderTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/OpenIddictBuilderTests.cs
@@ -16,7 +16,7 @@ namespace OpenIddict.Abstractions.Tests
public void Constructor_ThrowsAnExceptionForNullServices()
{
// Arrange
- var services = (IServiceCollection) null;
+ var services = (IServiceCollection) null!;
// Act and assert
var exception = Assert.Throws(() => new OpenIddictBuilder(services));
diff --git a/test/OpenIddict.Abstractions.Tests/OpenIddictExtensionsTests.cs b/test/OpenIddict.Abstractions.Tests/OpenIddictExtensionsTests.cs
index a45524c8..9a91ba3d 100644
--- a/test/OpenIddict.Abstractions.Tests/OpenIddictExtensionsTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/OpenIddictExtensionsTests.cs
@@ -16,7 +16,7 @@ namespace OpenIddict.Abstractions.Tests
public void AddOpenIddict_ThrowsAnExceptionForNullServices()
{
// Arrange
- var services = (IServiceCollection) null;
+ var services = (IServiceCollection) null!;
// Act and assert
var exception = Assert.Throws(() => services.AddOpenIddict());
@@ -31,7 +31,7 @@ namespace OpenIddict.Abstractions.Tests
var services = new ServiceCollection();
// Act and assert
- var exception = Assert.Throws(() => services.AddOpenIddict(configuration: null));
+ var exception = Assert.Throws(() => services.AddOpenIddict(configuration: null!));
Assert.Equal("configuration", exception.ParamName);
}
diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictConverterTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictConverterTests.cs
index 520b410a..93206659 100644
--- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictConverterTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictConverterTests.cs
@@ -22,7 +22,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var converter = new OpenIddictConverter();
// Act and assert
- var exception = Assert.Throws(() => converter.CanConvert(typeToConvert: null));
+ var exception = Assert.Throws(() => converter.CanConvert(typeToConvert: null!));
Assert.Equal("typeToConvert", exception.ParamName);
}
@@ -59,7 +59,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var exception = Assert.Throws(delegate
{
var reader = new Utf8JsonReader();
- return converter.Read(ref reader, typeToConvert: null, options: null);
+ return converter.Read(ref reader, typeToConvert: null!, options: null!);
});
Assert.Equal("typeToConvert", exception.ParamName);
@@ -84,7 +84,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var exception = Assert.Throws(delegate
{
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(@"{""name"":""value""}"));
- return converter.Read(ref reader, type, options: null);
+ return converter.Read(ref reader, type, options: null!);
});
Assert.StartsWith(SR.GetResourceString(SR.ID0176), exception.Message);
@@ -102,11 +102,11 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(@"{""name"":""value""}"));
// Act
- var message = converter.Read(ref reader, type, options: null);
+ var message = converter.Read(ref reader, type, options: null!);
// Assert
Assert.IsType(type, message);
- Assert.Equal("value", (string) message.GetParameter("name"));
+ Assert.Equal("value", (string?) message.GetParameter("name"));
}
[Fact]
@@ -118,7 +118,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
@"{""string"":null,""bool"":null,""long"":null,""array"":null,""object"":null}"));
// Act
- var message = converter.Read(ref reader, typeof(OpenIddictMessage), options: null);
+ var message = converter.Read(ref reader, typeof(OpenIddictMessage), options: null!);
// Assert
Assert.Equal(5, message.Count);
@@ -127,7 +127,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
Assert.NotNull(message.GetParameter("long"));
Assert.NotNull(message.GetParameter("array"));
Assert.NotNull(message.GetParameter("object"));
- Assert.Null((string) message.GetParameter("string"));
+ Assert.Null((string?) message.GetParameter("string"));
Assert.Null((bool?) message.GetParameter("bool"));
Assert.Null((long?) message.GetParameter("long"));
Assert.Equal(JsonValueKind.Null, ((JsonElement) message.GetParameter("array")).ValueKind);
@@ -142,14 +142,14 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(@"{""string"":"""",""array"":[],""object"":{}}"));
// Act
- var message = converter.Read(ref reader, typeof(OpenIddictMessage), options: null);
+ var message = converter.Read(ref reader, typeof(OpenIddictMessage), options: null!);
// Assert
Assert.Equal(3, message.Count);
Assert.NotNull(message.GetParameter("string"));
Assert.NotNull(message.GetParameter("array"));
Assert.NotNull(message.GetParameter("object"));
- Assert.Empty((string) message.GetParameter("string"));
+ Assert.Empty((string?) message.GetParameter("string"));
Assert.NotNull((JsonElement?) message.GetParameter("array"));
Assert.NotNull((JsonElement?) message.GetParameter("object"));
}
@@ -163,7 +163,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
var exception = Assert.Throws(() =>
{
- converter.Write(writer: null, value: null, options: null);
+ converter.Write(writer: null!, value: null!, options: null!);
});
Assert.Equal("writer", exception.ParamName);
@@ -178,7 +178,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
var exception = Assert.Throws(() =>
{
- converter.Write(writer: new Utf8JsonWriter(Stream.Null), value: null, options: null);
+ converter.Write(writer: new Utf8JsonWriter(Stream.Null), value: null!, options: null!);
});
Assert.Equal("value", exception.ParamName);
@@ -195,7 +195,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
using var writer = new Utf8JsonWriter(stream);
// Act
- converter.Write(writer, value: message, options: null);
+ converter.Write(writer, value: message, options: null!);
// Assert
writer.Flush();
@@ -213,13 +213,13 @@ namespace OpenIddict.Abstractions.Tests.Primitives
using var writer = new Utf8JsonWriter(stream);
var message = new OpenIddictMessage();
- message.AddParameter("string", new OpenIddictParameter((string) null));
+ message.AddParameter("string", new OpenIddictParameter((string?) null));
message.AddParameter("bool", new OpenIddictParameter((bool?) null));
message.AddParameter("long", new OpenIddictParameter((long?) null));
message.AddParameter("node", new OpenIddictParameter(default(JsonElement)));
// Act
- converter.Write(writer, value: message, options: null);
+ converter.Write(writer, value: message, options: null!);
// Assert
writer.Flush();
@@ -242,7 +242,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
message.AddParameter("object", new OpenIddictParameter(JsonSerializer.Deserialize("{}")));
// Act
- converter.Write(writer, value: message, options: null);
+ converter.Write(writer, value: message, options: null!);
// Assert
writer.Flush();
@@ -264,7 +264,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
message.AddParameter("array", new[] { "value" });
// Act
- converter.Write(writer, value: message, options: null);
+ converter.Write(writer, value: message, options: null!);
// Assert
writer.Flush();
diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs
index 15a9817f..b90389c1 100644
--- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictExtensionsTests.cs
@@ -22,7 +22,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetAcrValues_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.GetAcrValues());
@@ -57,7 +57,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetPrompts_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act
var exception = Assert.Throws(() => request.GetPrompts());
@@ -93,7 +93,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetResponseTypes_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act
var exception = Assert.Throws(() => request.GetResponseTypes());
@@ -129,7 +129,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetScopes_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.GetScopes());
@@ -164,7 +164,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasAcrValue_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.HasAcrValue("mod-mf"));
@@ -225,7 +225,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasPrompt_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() =>
@@ -289,7 +289,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasResponseType_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() =>
@@ -353,7 +353,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasScope_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() =>
@@ -415,7 +415,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsNoneFlow_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsNoneFlow());
@@ -456,7 +456,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsAuthorizationCodeFlow_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsAuthorizationCodeFlow());
@@ -497,7 +497,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsImplicitFlow_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsImplicitFlow());
@@ -550,7 +550,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsHybridFlow_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsHybridFlow());
@@ -605,7 +605,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsFragmentResponseMode_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsFragmentResponseMode());
@@ -656,7 +656,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsQueryResponseMode_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsQueryResponseMode());
@@ -707,7 +707,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsFormPostResponseMode_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsFormPostResponseMode());
@@ -743,7 +743,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsAuthorizationCodeGrantType_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsAuthorizationCodeGrantType());
@@ -782,7 +782,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsClientCredentialsGrantType_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsClientCredentialsGrantType());
@@ -821,7 +821,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsDeviceCodeGrantType_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsDeviceCodeGrantType());
@@ -860,7 +860,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsPasswordGrantType_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsPasswordGrantType());
@@ -899,7 +899,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void IsRefreshTokenGrantType_ThrowsAnExceptionForNullRequest()
{
// Arrange
- var request = (OpenIddictRequest) null;
+ var request = (OpenIddictRequest) null!;
// Act and assert
var exception = Assert.Throws(() => request.IsRefreshTokenGrantType());
@@ -938,7 +938,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void Claim_GetDestinations_ThrowsAnExceptionForNullClaim()
{
// Arrange
- var claim = (Claim) null;
+ var claim = (Claim) null!;
// Act and assert
var exception = Assert.Throws(() => claim.GetDestinations());
@@ -968,7 +968,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void Claim_HasDestination_ThrowsAnExceptionForNullClaim()
{
// Arrange
- var claim = (Claim) null;
+ var claim = (Claim) null!;
// Act and assert
var exception = Assert.Throws(() => claim.HasDestination("destination"));
@@ -983,7 +983,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var claim = new Claim(Claims.Name, "Bob le Bricoleur");
// Act and assert
- var exception = Assert.Throws(() => claim.HasDestination(null));
+ var exception = Assert.Throws(() => claim.HasDestination(null!));
Assert.Equal("destination", exception.ParamName);
Assert.StartsWith(SR.GetResourceString(SR.ID0181), exception.Message);
@@ -1021,7 +1021,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void Claim_SetDestinations_ThrowsAnExceptionForNullClaim()
{
// Arrange
- var claim = (Claim) null;
+ var claim = (Claim) null!;
// Act and assert
var exception = Assert.Throws(() => claim.SetDestinations());
@@ -1080,7 +1080,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void ClaimsPrincipal_GetDestinations_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetDestinations());
@@ -1126,10 +1126,10 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void ClaimsPrincipal_SetDestinations_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
- var exception = Assert.Throws(() => principal.SetDestinations(destinations: null));
+ var exception = Assert.Throws(() => principal.SetDestinations(destinations: null!));
Assert.Equal("principal", exception.ParamName);
}
@@ -1139,7 +1139,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
{
// Arrange
var principal = new ClaimsPrincipal(new ClaimsIdentity());
- var destinations = (ImmutableDictionary) null;
+ var destinations = (ImmutableDictionary) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetDestinations(destinations));
@@ -1287,7 +1287,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void AddClaim_ThrowsAnExceptionForNullIdentity()
{
// Arrange
- var identity = (ClaimsIdentity) null;
+ var identity = (ClaimsIdentity) null!;
// Act and assert
var exception = Assert.Throws(() =>
@@ -1355,7 +1355,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetClaim_ThrowsAnExceptionForNullIdentity()
{
// Arrange
- var identity = (ClaimsIdentity) null;
+ var identity = (ClaimsIdentity) null!;
// Act and assert
var exception = Assert.Throws(() =>
@@ -1396,7 +1396,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void ClaimsIdentity_Clone_ThrowsAnExceptionForNullIdentity()
{
// Arrange
- var identity = (ClaimsIdentity) null;
+ var identity = (ClaimsIdentity) null!;
// Act and assert
var exception = Assert.Throws(() => identity.Clone(claim => true));
@@ -1423,7 +1423,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void ClaimsPrincipal_Clone_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.Clone(claim => true));
@@ -1486,7 +1486,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetClaim_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetClaim("type"));
@@ -1521,7 +1521,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetCreationDate_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetCreationDate());
@@ -1559,7 +1559,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetExpirationDate_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetExpirationDate());
@@ -1596,7 +1596,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetAudiences_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetAudiences());
@@ -1626,7 +1626,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetPresenters_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetPresenters());
@@ -1656,7 +1656,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetResources_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetResources());
@@ -1686,7 +1686,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetScopes_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetScopes());
@@ -1716,7 +1716,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetAccessTokenLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetAccessTokenLifetime());
@@ -1743,7 +1743,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetAuthorizationCodeLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetAuthorizationCodeLifetime());
@@ -1770,7 +1770,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetDeviceCodeLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetDeviceCodeLifetime());
@@ -1797,7 +1797,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetIdentityTokenLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetIdentityTokenLifetime());
@@ -1824,7 +1824,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetRefreshTokenLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetRefreshTokenLifetime());
@@ -1851,7 +1851,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetUserCodeLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetUserCodeLifetime());
@@ -1878,7 +1878,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetAuthorizationId_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetAuthorizationId());
@@ -1905,7 +1905,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetTokenId_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetTokenId());
@@ -1932,7 +1932,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetTokenType_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetTokenType());
@@ -1959,7 +1959,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasAudience_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.HasAudience("Fabrikam"));
@@ -2023,7 +2023,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasPresenter_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.HasPresenter("Fabrikam"));
@@ -2087,7 +2087,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasResource_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.HasResource("Fabrikam"));
@@ -2151,7 +2151,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasScope_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.HasScope(Scopes.OpenId));
@@ -2215,7 +2215,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasTokenType_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.HasTokenType(TokenTypeHints.AccessToken));
@@ -2285,7 +2285,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetClaims_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.GetClaims("type"));
@@ -2327,7 +2327,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void HasClaim_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.HasClaim("type"));
@@ -2371,7 +2371,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void RemoveClaims_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.RemoveClaims("type"));
@@ -2414,7 +2414,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetClaim_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetClaim("type", "value"));
@@ -2483,7 +2483,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetCreationDate_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetCreationDate(date: null));
@@ -2509,7 +2509,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetExpirationDate_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetExpirationDate(date: null));
@@ -2535,7 +2535,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetAudiences_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetAudiences());
@@ -2567,7 +2567,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetPresenters_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetPresenters());
@@ -2599,7 +2599,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetResources_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetResources());
@@ -2631,7 +2631,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetScopes_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetScopes());
@@ -2703,7 +2703,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetAccessTokenLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetAccessTokenLifetime(null));
@@ -2731,7 +2731,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetAuthorizationCodeLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetAuthorizationCodeLifetime(null));
@@ -2759,7 +2759,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetDeviceCodeLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetDeviceCodeLifetime(null));
@@ -2787,7 +2787,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetIdentityTokenLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetIdentityTokenLifetime(null));
@@ -2815,7 +2815,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetRefreshTokenLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetRefreshTokenLifetime(null));
@@ -2843,7 +2843,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetUserCodeLifetime_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetUserCodeLifetime(null));
@@ -2871,7 +2871,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetAuthorizationId_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetAuthorizationId(null));
@@ -2899,7 +2899,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetTokenId_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetTokenId(null));
@@ -2927,7 +2927,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void SetTokenType_ThrowsAnExceptionForNullPrincipal()
{
// Arrange
- var principal = (ClaimsPrincipal) null;
+ var principal = (ClaimsPrincipal) null!;
// Act and assert
var exception = Assert.Throws(() => principal.SetTokenType(null));
diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs
index a1f060de..008f910b 100644
--- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictMessageTests.cs
@@ -85,7 +85,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Arrange and act
var message = new OpenIddictMessage(new[]
{
- new KeyValuePair("null-parameter", (string) null),
+ new KeyValuePair("null-parameter", (string?) null),
new KeyValuePair("empty-parameter", string.Empty)
});
@@ -99,13 +99,13 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Arrange and act
var message = new OpenIddictMessage(new[]
{
- new KeyValuePair("parameter", "Fabrikam"),
- new KeyValuePair("parameter", "Contoso")
+ new KeyValuePair("parameter", "Fabrikam"),
+ new KeyValuePair("parameter", "Contoso")
});
// Assert
Assert.Equal(1, message.Count);
- Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]) message.GetParameter("parameter"));
+ Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]?) message.GetParameter("parameter"));
}
[Fact]
@@ -114,12 +114,12 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Arrange and act
var message = new OpenIddictMessage(new[]
{
- new KeyValuePair("parameter", new[] { "Fabrikam", "Contoso" })
+ new KeyValuePair("parameter", new[] { "Fabrikam", "Contoso" })
});
// Assert
Assert.Equal(1, message.Count);
- Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]) message.GetParameter("parameter"));
+ Assert.Equal(new[] { "Fabrikam", "Contoso" }, (string[]?) message.GetParameter("parameter"));
}
[Fact]
@@ -128,7 +128,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Arrange and act
var message = new OpenIddictMessage(new[]
{
- new KeyValuePair("parameter", new[] { "Fabrikam" })
+ new KeyValuePair("parameter", new[] { "Fabrikam" })
});
// Assert
@@ -194,7 +194,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
@"{""property"":""""}").GetProperty("property").GetString());
// Assert
- Assert.Empty((string) message.GetParameter("string"));
+ Assert.Empty((string?) message.GetParameter("string"));
Assert.NotNull((JsonElement?) message.GetParameter("array"));
Assert.NotNull((JsonElement?) message.GetParameter("object"));
Assert.NotNull((JsonElement?) message.GetParameter("value"));
@@ -421,7 +421,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
Assert.True(message.TryGetParameter("parameter", out var parameter));
- Assert.Equal(42, (long) parameter.Value);
+ Assert.Equal(42, (long?) parameter.Value);
}
[Fact]
@@ -491,7 +491,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var message = new OpenIddictMessage();
// Act and assert
- var exception = Assert.Throws(() => message.WriteTo(writer: null));
+ var exception = Assert.Throws(() => message.WriteTo(writer: null!));
Assert.Equal("writer", exception.ParamName);
}
diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs
index 5c1ef1d5..2cef4d87 100644
--- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs
@@ -323,7 +323,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
JsonSerializer.Deserialize(@"{""parameter"":""value""}"));
// Act and assert
- Assert.Equal("value", (string) parameter.GetNamedParameter("parameter"));
+ Assert.Equal("value", (string?) parameter.GetNamedParameter("parameter"));
}
[Fact]
@@ -375,7 +375,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
});
// Act and assert
- Assert.Equal("Fabrikam", (string) parameter.GetUnnamedParameter(0));
+ Assert.Equal("Fabrikam", (string?) parameter.GetUnnamedParameter(0));
}
[Fact]
@@ -408,7 +408,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
JsonSerializer.Deserialize(@"[""Fabrikam"",""Contoso""]"));
// Act and assert
- Assert.Equal("Fabrikam", (string) parameter.GetUnnamedParameter(0));
+ Assert.Equal("Fabrikam", (string?) parameter.GetUnnamedParameter(0));
}
[Fact]
@@ -463,7 +463,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void GetNamedParameters_ReturnsExpectedParametersForJsonObjects()
{
// Arrange
- var parameters = new Dictionary
+ var parameters = new Dictionary
{
["parameter"] = "value"
};
@@ -472,7 +472,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
JsonSerializer.Deserialize(@"{""parameter"":""value""}"));
// Act and assert
- Assert.Equal(parameters, parameter.GetNamedParameters().ToDictionary(pair => pair.Key, pair => (string) pair.Value));
+ Assert.Equal(parameters, parameter.GetNamedParameters().ToDictionary(pair => pair.Key, pair => (string?) pair.Value));
}
[Fact]
@@ -510,7 +510,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
Assert.Equal(parameters, from element in parameter.GetUnnamedParameters()
- select (string) element);
+ select (string?) element);
}
[Fact]
@@ -539,7 +539,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
Assert.Equal(parameters, from element in parameter.GetUnnamedParameters()
- select (string) element);
+ select (string?) element);
}
[Fact]
@@ -559,8 +559,8 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Arrange, act and assert
Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter((bool?) null)));
Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter((long?) null)));
- Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter((string) null)));
- Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter((string[]) null)));
+ Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter((string?) null)));
+ Assert.True(OpenIddictParameter.IsNullOrEmpty(new OpenIddictParameter((string[]?) null)));
}
[Fact]
@@ -760,7 +760,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
Assert.True(parameter.TryGetNamedParameter("parameter", out var value));
- Assert.Equal("value", (string) value);
+ Assert.Equal("value", (string?) value);
}
[Fact]
@@ -815,7 +815,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
Assert.True(parameter.TryGetUnnamedParameter(0, out var value));
- Assert.Equal("Fabrikam", (string) value);
+ Assert.Equal("Fabrikam", (string?) value);
}
[Fact]
@@ -851,7 +851,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
// Act and assert
Assert.True(parameter.TryGetUnnamedParameter(0, out var value));
- Assert.Equal("Fabrikam", (string) value);
+ Assert.Equal("Fabrikam", (string?) value);
}
[Fact]
@@ -861,7 +861,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var parameter = new OpenIddictParameter();
// Act and assert
- var exception = Assert.Throws(() => parameter.WriteTo(writer: null));
+ var exception = Assert.Throws(() => parameter.WriteTo(writer: null!));
Assert.Equal("writer", exception.ParamName);
}
@@ -890,11 +890,11 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void BoolConverter_CanCreateParameterFromBooleanValue()
{
// Arrange, act and assert
- Assert.True((bool) new OpenIddictParameter(true).Value);
- Assert.True((bool) new OpenIddictParameter((bool?) true).Value);
+ Assert.True((bool?) new OpenIddictParameter(true).Value);
+ Assert.True((bool?) new OpenIddictParameter((bool?) true).Value);
- Assert.False((bool) new OpenIddictParameter(false).Value);
- Assert.False((bool) new OpenIddictParameter((bool?) false).Value);
+ Assert.False((bool?) new OpenIddictParameter(false).Value);
+ Assert.False((bool?) new OpenIddictParameter((bool?) false).Value);
}
[Fact]
@@ -1037,8 +1037,8 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void LongConverter_CanCreateParameterFromLongValue()
{
// Arrange, act and assert
- Assert.Equal(42, (long) new OpenIddictParameter(42).Value);
- Assert.Equal(42, (long) new OpenIddictParameter((long?) 42).Value);
+ Assert.Equal(42, (long?) new OpenIddictParameter(42).Value);
+ Assert.Equal(42, (long?) new OpenIddictParameter((long?) 42).Value);
}
[Fact]
@@ -1077,9 +1077,9 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void LongConverter_CanConvertFromPrimitiveValues()
{
// Arrange, act and assert
- Assert.Equal(42, (long) new OpenIddictParameter(42));
Assert.Equal(42, (long?) new OpenIddictParameter(42));
- Assert.Equal(42, (long) new OpenIddictParameter(42));
+ Assert.Equal(42, (long?) new OpenIddictParameter(42));
+ Assert.Equal(42, (long?) new OpenIddictParameter(42));
Assert.Equal(42, (long?) new OpenIddictParameter(42));
}
@@ -1087,7 +1087,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void LongConverter_CanConvertFromJsonValues()
{
// Arrange, act and assert
- Assert.Equal(42, (long) new OpenIddictParameter(
+ Assert.Equal(42, (long?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":42}").GetProperty("field")));
Assert.Equal(42, (long?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":42}").GetProperty("field")));
@@ -1097,31 +1097,31 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void StringConverter_CanCreateParameterFromStringValue()
{
// Arrange, act and assert
- Assert.Equal("Fabrikam", (string) new OpenIddictParameter("Fabrikam").Value);
+ Assert.Equal("Fabrikam", (string?) new OpenIddictParameter("Fabrikam").Value);
}
[Fact]
public void StringConverter_ReturnsDefaultValueForNullValues()
{
// Arrange, act and assert
- Assert.Null((string) new OpenIddictParameter());
- Assert.Null((string) (OpenIddictParameter?) null);
+ Assert.Null((string?) new OpenIddictParameter());
+ Assert.Null((string?) (OpenIddictParameter?) null);
}
[Fact]
public void StringConverter_ReturnsDefaultValueForArrays()
{
// Arrange, act and assert
- Assert.Null((string) new OpenIddictParameter(new[] { "Contoso", "Fabrikam" }));
+ Assert.Null((string?) new OpenIddictParameter(new[] { "Contoso", "Fabrikam" }));
}
[Fact]
public void StringConverter_ReturnsDefaultValueForUnsupportedJsonValues()
{
// Arrange, act and assert
- Assert.Null((string) new OpenIddictParameter(
+ Assert.Null((string?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"[""Contoso"",""Fabrikam""]")));
- Assert.Null((string) new OpenIddictParameter(
+ Assert.Null((string?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":""Fabrikam""}")));
}
@@ -1129,20 +1129,20 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void StringConverter_CanConvertFromPrimitiveValues()
{
// Arrange, act and assert
- Assert.Equal("Fabrikam", (string) new OpenIddictParameter("Fabrikam"));
- Assert.Equal("False", (string) new OpenIddictParameter(false));
- Assert.Equal("42", (string) new OpenIddictParameter(42));
+ Assert.Equal("Fabrikam", (string?) new OpenIddictParameter("Fabrikam"));
+ Assert.Equal("False", (string?) new OpenIddictParameter(false));
+ Assert.Equal("42", (string?) new OpenIddictParameter(42));
}
[Fact]
public void StringConverter_CanConvertFromJsonValues()
{
// Arrange, act and assert
- Assert.Equal("Fabrikam", (string) new OpenIddictParameter(
+ Assert.Equal("Fabrikam", (string?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":""Fabrikam""}").GetProperty("field")));
- Assert.Equal(bool.FalseString, (string) new OpenIddictParameter(
+ Assert.Equal(bool.FalseString, (string?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":false}").GetProperty("field")));
- Assert.Equal("42", (string) new OpenIddictParameter(
+ Assert.Equal("42", (string?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":42}").GetProperty("field")));
}
@@ -1163,45 +1163,45 @@ namespace OpenIddict.Abstractions.Tests.Primitives
public void StringArrayConverter_CanCreateParameterFromPrimitiveValues()
{
// Arrange, act and assert
- Assert.Equal(new[] { "Fabrikam" }, (string[]) new OpenIddictParameter("Fabrikam"));
- Assert.Equal(new[] { "False" }, (string[]) new OpenIddictParameter(false));
- Assert.Equal(new[] { "42" }, (string[]) new OpenIddictParameter(42));
+ Assert.Equal(new[] { "Fabrikam" }, (string[]?) new OpenIddictParameter("Fabrikam"));
+ Assert.Equal(new[] { "False" }, (string[]?) new OpenIddictParameter(false));
+ Assert.Equal(new[] { "42" }, (string[]?) new OpenIddictParameter(42));
}
[Fact]
public void StringArrayConverter_ReturnsDefaultValueForNullValues()
{
// Arrange, act and assert
- Assert.Null((string[]) new OpenIddictParameter());
+ Assert.Null((string[]?) new OpenIddictParameter());
}
[Fact]
public void StringArrayConverter_ReturnsSingleElementArrayForStringValue()
{
// Arrange, act and assert
- Assert.Equal(new[] { "Fabrikam" }, (string[]) new OpenIddictParameter("Fabrikam"));
+ Assert.Equal(new[] { "Fabrikam" }, (string[]?) new OpenIddictParameter("Fabrikam"));
}
[Fact]
public void StringArrayConverter_ReturnsDefaultValueForUnsupportedJsonValues()
{
// Arrange, act and assert
- Assert.Null((string[]) new OpenIddictParameter(new JsonElement()));
+ Assert.Null((string[]?) new OpenIddictParameter(new JsonElement()));
}
[Fact]
public void StringArrayConverter_CanConvertFromJsonValues()
{
// Arrange, act and assert
- Assert.Equal(new[] { "Fabrikam" }, (string[]) new OpenIddictParameter(
+ Assert.Equal(new[] { "Fabrikam" }, (string[]?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":""Fabrikam""}").GetProperty("field")));
- Assert.Equal(new[] { "False" }, (string[]) new OpenIddictParameter(
+ Assert.Equal(new[] { "False" }, (string[]?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":false}").GetProperty("field")));
- Assert.Equal(new[] { "42" }, (string[]) new OpenIddictParameter(
+ Assert.Equal(new[] { "42" }, (string[]?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"{""field"":42}").GetProperty("field")));
- Assert.Equal(new[] { "Fabrikam" }, (string[]) new OpenIddictParameter(
+ Assert.Equal(new[] { "Fabrikam" }, (string[]?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"[""Fabrikam""]")));
- Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]) new OpenIddictParameter(
+ Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) new OpenIddictParameter(
JsonSerializer.Deserialize(@"[""Contoso"",""Fabrikam""]")));
}
}
diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictRequestTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictRequestTests.cs
index 201c905a..d397f017 100644
--- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictRequestTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictRequestTests.cs
@@ -1,3 +1,4 @@
+
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
@@ -315,7 +316,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
request.SetParameter(name, value);
// Act and assert
- Assert.Equal(value.Value, typeof(OpenIddictRequest).GetProperty(property).GetValue(request));
+ Assert.Equal(value.Value, typeof(OpenIddictRequest).GetProperty(property)!.GetValue(request));
}
[Theory]
@@ -326,7 +327,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var request = new OpenIddictRequest();
// Act
- typeof(OpenIddictRequest).GetProperty(property).SetValue(request, value.Value);
+ typeof(OpenIddictRequest).GetProperty(property)!.SetValue(request, value.Value);
// Assert
Assert.Equal(value, request.GetParameter(name));
diff --git a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictResponseTests.cs b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictResponseTests.cs
index 3f8f089c..63da9f02 100644
--- a/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictResponseTests.cs
+++ b/test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictResponseTests.cs
@@ -1,3 +1,4 @@
+
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
@@ -118,7 +119,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
response.SetParameter(name, value);
// Act and assert
- Assert.Equal(value.Value, typeof(OpenIddictResponse).GetProperty(property).GetValue(response));
+ Assert.Equal(value.Value, typeof(OpenIddictResponse).GetProperty(property)!.GetValue(response));
}
[Theory]
@@ -129,7 +130,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
var response = new OpenIddictResponse();
// Act
- typeof(OpenIddictResponse).GetProperty(property).SetValue(response, value.Value);
+ typeof(OpenIddictResponse).GetProperty(property)!.SetValue(response, value.Value);
// Assert
Assert.Equal(value, response.GetParameter(name));
diff --git a/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj b/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj
index 6114811b..7ba6df68 100644
--- a/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj
+++ b/test/OpenIddict.Core.Tests/OpenIddict.Core.Tests.csproj
@@ -2,6 +2,7 @@
net461;netcoreapp2.1;netcoreapp3.1
+ enable
diff --git a/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs b/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs
index f9966977..3525c2f5 100644
--- a/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs
+++ b/test/OpenIddict.Core.Tests/OpenIddictCoreBuilderTests.cs
@@ -22,7 +22,7 @@ namespace OpenIddict.Core.Tests
public void Constructor_ThrowsAnExceptionForNullServices()
{
// Arrange
- var services = (IServiceCollection) null;
+ var services = (IServiceCollection) null!;
// Act and assert
var exception = Assert.Throws(() => new OpenIddictCoreBuilder(services));
@@ -437,7 +437,7 @@ namespace OpenIddict.Core.Tests
// Act and assert
var exception = Assert.Throws(delegate
{
- return builder.SetDefaultApplicationEntity(type: null);
+ return builder.SetDefaultApplicationEntity(type: null!);
});
Assert.Equal("type", exception.ParamName);
@@ -487,7 +487,7 @@ namespace OpenIddict.Core.Tests
// Act and assert
var exception = Assert.Throws(delegate
{
- return builder.SetDefaultAuthorizationEntity(type: null);
+ return builder.SetDefaultAuthorizationEntity(type: null!);
});
Assert.Equal("type", exception.ParamName);
@@ -537,7 +537,7 @@ namespace OpenIddict.Core.Tests
// Act and assert
var exception = Assert.Throws(delegate
{
- return builder.SetDefaultScopeEntity(type: null);
+ return builder.SetDefaultScopeEntity(type: null!);
});
Assert.Equal("type", exception.ParamName);
@@ -587,7 +587,7 @@ namespace OpenIddict.Core.Tests
// Act and assert
var exception = Assert.Throws(delegate
{
- return builder.SetDefaultTokenEntity(type: null);
+ return builder.SetDefaultTokenEntity(type: null!);
});
Assert.Equal("type", exception.ParamName);
diff --git a/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs b/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs
index 00cc05fa..74f01012 100644
--- a/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs
+++ b/test/OpenIddict.Core.Tests/OpenIddictCoreExtensionsTests.cs
@@ -21,7 +21,7 @@ namespace OpenIddict.Core.Tests
public void AddCore_ThrowsAnExceptionForNullBuilder()
{
// Arrange
- var builder = (OpenIddictBuilder) null;
+ var builder = (OpenIddictBuilder) null!;
// Act and assert
var exception = Assert.Throws(() => builder.AddCore());
@@ -37,7 +37,7 @@ namespace OpenIddict.Core.Tests
var builder = new OpenIddictBuilder(services);
// Act and assert
- var exception = Assert.Throws(() => builder.AddCore(configuration: null));
+ var exception = Assert.Throws(() => builder.AddCore(configuration: null!));
Assert.Equal("configuration", exception.ParamName);
}
diff --git a/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj b/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj
index b20e570c..1587d07f 100644
--- a/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj
+++ b/test/OpenIddict.EntityFramework.Tests/OpenIddict.EntityFramework.Tests.csproj
@@ -2,6 +2,7 @@
net461;netcoreapp3.1
+ enable
diff --git a/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkBuilderTests.cs b/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkBuilderTests.cs
index 9ad57976..b4e0307e 100644
--- a/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkBuilderTests.cs
+++ b/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkBuilderTests.cs
@@ -21,7 +21,7 @@ namespace OpenIddict.EntityFramework.Tests
public void Constructor_ThrowsAnExceptionForNullServices()
{
// Arrange
- var services = (IServiceCollection) null;
+ var services = (IServiceCollection) null!;
// Act and assert
var exception = Assert.Throws(() => new OpenIddictEntityFrameworkBuilder(services));
@@ -59,7 +59,7 @@ namespace OpenIddict.EntityFramework.Tests
// Act and assert
var exception = Assert.Throws(delegate
{
- return builder.UseDbContext(type: null);
+ return builder.UseDbContext(type: null!);
});
Assert.Equal("type", exception.ParamName);
diff --git a/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkExtensionsTests.cs b/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkExtensionsTests.cs
index eb3f8c25..8d97b051 100644
--- a/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkExtensionsTests.cs
+++ b/test/OpenIddict.EntityFramework.Tests/OpenIddictEntityFrameworkExtensionsTests.cs
@@ -20,7 +20,7 @@ namespace OpenIddict.EntityFramework.Tests
public void UseEntityFramework_ThrowsAnExceptionForNullBuilder()
{
// Arrange
- var builder = (OpenIddictCoreBuilder) null;
+ var builder = (OpenIddictCoreBuilder) null!;
// Act and assert
var exception = Assert.Throws(() => builder.UseEntityFramework());
@@ -36,7 +36,7 @@ namespace OpenIddict.EntityFramework.Tests
var builder = new OpenIddictCoreBuilder(services);
// Act and assert
- var exception = Assert.Throws(() => builder.UseEntityFramework(configuration: null));
+ var exception = Assert.Throws(() => builder.UseEntityFramework(configuration: null!));
Assert.Equal("configuration", exception.ParamName);
}
diff --git a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj
index e70bb2d5..6d1e710c 100644
--- a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj
+++ b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddict.EntityFrameworkCore.Tests.csproj
@@ -2,6 +2,7 @@
net461;netcoreapp2.1;netcoreapp3.1
+ enable
diff --git a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreBuilderTests.cs b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreBuilderTests.cs
index f33930d0..022263d5 100644
--- a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreBuilderTests.cs
+++ b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreBuilderTests.cs
@@ -21,7 +21,7 @@ namespace OpenIddict.EntityFrameworkCore.Tests
public void Constructor_ThrowsAnExceptionForNullServices()
{
// Arrange
- var services = (IServiceCollection) null;
+ var services = (IServiceCollection) null!;
// Act and assert
var exception = Assert.Throws(() => new OpenIddictEntityFrameworkCoreBuilder(services));
@@ -79,7 +79,7 @@ namespace OpenIddict.EntityFrameworkCore.Tests
// Act and assert
var exception = Assert.Throws(delegate
{
- return builder.UseDbContext(type: null);
+ return builder.UseDbContext(type: null!);
});
Assert.Equal("type", exception.ParamName);
diff --git a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs
index 92b75956..7d907c85 100644
--- a/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs
+++ b/test/OpenIddict.EntityFrameworkCore.Tests/OpenIddictEntityFrameworkCoreExtensionsTests.cs
@@ -20,7 +20,7 @@ namespace OpenIddict.EntityFrameworkCore.Tests
public void UseEntityFrameworkCore_ThrowsAnExceptionForNullBuilder()
{
// Arrange
- var builder = (OpenIddictCoreBuilder) null;
+ var builder = (OpenIddictCoreBuilder) null!;
// Act and assert
var exception = Assert.Throws(() => builder.UseEntityFrameworkCore());
@@ -36,7 +36,7 @@ namespace OpenIddict.EntityFrameworkCore.Tests
var builder = new OpenIddictCoreBuilder(services);
// Act and assert
- var exception = Assert.Throws(() => builder.UseEntityFrameworkCore(configuration: null));
+ var exception = Assert.Throws(() => builder.UseEntityFrameworkCore(configuration: null!));
Assert.Equal("configuration", exception.ParamName);
}
diff --git a/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj b/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj
index b3638efd..90250be4 100644
--- a/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj
+++ b/test/OpenIddict.MongoDb.Tests/OpenIddict.MongoDb.Tests.csproj
@@ -4,6 +4,7 @@
net461;netcoreapp2.1;netcoreapp3.1
false
false
+ enable
diff --git a/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs b/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs
index 67e3c9a1..213649aa 100644
--- a/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs
+++ b/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs
@@ -22,7 +22,7 @@ namespace OpenIddict.MongoDb.Tests
public void Constructor_ThrowsAnExceptionForNullServices()
{
// Arrange
- var services = (IServiceCollection) null;
+ var services = (IServiceCollection) null!;
// Act and assert
var exception = Assert.Throws(() => new OpenIddictMongoDbBuilder(services));
@@ -240,7 +240,7 @@ namespace OpenIddict.MongoDb.Tests
// Act and assert
var exception = Assert.Throws(delegate
{
- return builder.UseDatabase(database: null);
+ return builder.UseDatabase(database: null!);
});
Assert.Equal("database", exception.ParamName);
diff --git a/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbExtensionsTests.cs b/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbExtensionsTests.cs
index 38120f37..8d2d5aa8 100644
--- a/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbExtensionsTests.cs
+++ b/test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbExtensionsTests.cs
@@ -20,7 +20,7 @@ namespace OpenIddict.MongoDb.Tests
public void UseMongoDb_ThrowsAnExceptionForNullBuilder()
{
// Arrange
- var builder = (OpenIddictCoreBuilder) null;
+ var builder = (OpenIddictCoreBuilder) null!;
// Act and assert
var exception = Assert.Throws(() => builder.UseMongoDb());
@@ -36,7 +36,7 @@ namespace OpenIddict.MongoDb.Tests
var builder = new OpenIddictCoreBuilder(services);
// Act and assert
- var exception = Assert.Throws(() => builder.UseMongoDb(configuration: null));
+ var exception = Assert.Throws(() => builder.UseMongoDb(configuration: null!));
Assert.Equal("configuration", exception.ParamName);
}
diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj
index f7e49984..143e2666 100644
--- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj
+++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddict.Server.AspNetCore.IntegrationTests.csproj
@@ -2,6 +2,7 @@
net461;net472;net48;netcoreapp2.1;netcoreapp3.1
+ enable
diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs
index 0ed532c0..db7edca7 100644
--- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs
+++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTestServer.cs
@@ -17,29 +17,27 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
///
public class OpenIddictServerAspNetCoreIntegrationTestServer : OpenIddictServerIntegrationTestServer
{
- public OpenIddictServerAspNetCoreIntegrationTestServer(TestServer server)
- => Server = server;
-
#if SUPPORTS_GENERIC_HOST
public OpenIddictServerAspNetCoreIntegrationTestServer(IHost host)
{
Host = host;
Server = host.GetTestServer();
}
-#endif
-
- ///
- /// Gets the ASP.NET Core test server used by this instance.
- ///
- public TestServer Server { get; }
-#if SUPPORTS_GENERIC_HOST
///
/// Gets the generic host used by this instance.
///
public IHost Host { get; }
+#else
+ public OpenIddictServerAspNetCoreIntegrationTestServer(TestServer server)
+ => Server = server;
#endif
+ ///
+ /// Gets the ASP.NET Core test server used by this instance.
+ ///
+ public TestServer Server { get; }
+
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope",
Justification = "The caller is responsible of disposing the test client.")]
public override ValueTask CreateClientAsync()
diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Exchange.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Exchange.cs
index 8c7438cf..d1927bb8 100644
--- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Exchange.cs
+++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Exchange.cs
@@ -1,4 +1,5 @@
-/*
+
+/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
@@ -30,7 +31,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
{
builder.UseInlineHandler(context =>
{
- var request = context.Transaction.GetHttpRequest();
+ var request = context.Transaction.GetHttpRequest()!;
request.Headers[HeaderNames.Authorization] = "Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW";
return default;
diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Introspection.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Introspection.cs
index e243b12d..8c8f5c4f 100644
--- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Introspection.cs
+++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Introspection.cs
@@ -30,7 +30,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
{
builder.UseInlineHandler(context =>
{
- var request = context.Transaction.GetHttpRequest();
+ var request = context.Transaction.GetHttpRequest()!;
request.Headers[HeaderNames.Authorization] = "Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW";
return default;
diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Revocation.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Revocation.cs
index 7f56270c..9c01037a 100644
--- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Revocation.cs
+++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.Revocation.cs
@@ -30,7 +30,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
{
builder.UseInlineHandler(context =>
{
- var request = context.Transaction.GetHttpRequest();
+ var request = context.Transaction.GetHttpRequest()!;
request.Headers[HeaderNames.Authorization] = "Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW";
return default;
diff --git a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs
index beb9a5f7..8ea0c005 100644
--- a/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs
+++ b/test/OpenIddict.Server.AspNetCore.IntegrationTests/OpenIddictServerAspNetCoreIntegrationTests.cs
@@ -70,11 +70,11 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
Assert.Equal(JsonValueKind.True, ((JsonElement) response["boolean_parameter"]).ValueKind);
Assert.Equal(42, (long) response["integer_parameter"]);
Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind);
- Assert.Equal("Bob l'Eponge", (string) response["string_parameter"]);
+ Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]);
Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind);
- Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]) response["array_parameter"]);
+ Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["array_parameter"]);
Assert.Equal(JsonValueKind.Array, ((JsonElement) response["array_parameter"]).ValueKind);
- Assert.Equal("value", (string) response["object_parameter"]?["parameter"]);
+ Assert.Equal("value", (string?) response["object_parameter"]?["parameter"]);
Assert.Equal(JsonValueKind.Object, ((JsonElement) response["object_parameter"]).ValueKind);
}
@@ -328,7 +328,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
var response = await client.PostAsync(address, new OpenIddictRequest());
// Assert
- Assert.Equal("Bob le Bricoleur", (string) response["name"]);
+ Assert.Equal("Bob le Bricoleur", (string?) response["name"]);
}
[Theory]
@@ -363,7 +363,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
var response = await client.PostAsync(address, new OpenIddictRequest());
// Assert
- Assert.Equal("Bob le Magnifique", (string) response["name"]);
+ Assert.Equal("Bob le Magnifique", (string?) response["name"]);
}
[Fact]
@@ -399,11 +399,11 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
Assert.Equal(JsonValueKind.True, ((JsonElement) response["boolean_parameter"]).ValueKind);
Assert.Equal(42, (long) response["integer_parameter"]);
Assert.Equal(JsonValueKind.Number, ((JsonElement) response["integer_parameter"]).ValueKind);
- Assert.Equal("Bob l'Eponge", (string) response["string_parameter"]);
+ Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]);
Assert.Equal(JsonValueKind.String, ((JsonElement) response["string_parameter"]).ValueKind);
- Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]) response["array_parameter"]);
+ Assert.Equal(new[] { "Contoso", "Fabrikam" }, (string[]?) response["array_parameter"]);
Assert.Equal(JsonValueKind.Array, ((JsonElement) response["array_parameter"]).ValueKind);
- Assert.Equal("value", (string) response["object_parameter"]?["parameter"]);
+ Assert.Equal("value", (string?) response["object_parameter"]?["parameter"]);
Assert.Equal(JsonValueKind.Object, ((JsonElement) response["object_parameter"]).ValueKind);
}
@@ -437,7 +437,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
// Assert
Assert.True((bool) response["boolean_parameter"]);
Assert.Equal(42, (long) response["integer_parameter"]);
- Assert.Equal("Bob l'Eponge", (string) response["string_parameter"]);
+ Assert.Equal("Bob l'Eponge", (string?) response["string_parameter"]);
}
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope",
@@ -446,7 +446,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
#if SUPPORTS_GENERIC_HOST
async
#endif
- ValueTask CreateServerAsync(Action configuration = null)
+ ValueTask CreateServerAsync(Action? configuration = null)
{
#if SUPPORTS_GENERIC_HOST
var builder = new HostBuilder();
@@ -498,7 +498,7 @@ namespace OpenIddict.Server.AspNetCore.IntegrationTests
await next(context);
var feature = context.Features.Get();
- var response = feature?.Transaction.GetProperty