diff --git a/src/JWT/Builder/JwtBuilder.cs b/src/JWT/Builder/JwtBuilder.cs index dc6a55033..31cecbdfb 100644 --- a/src/JWT/Builder/JwtBuilder.cs +++ b/src/JWT/Builder/JwtBuilder.cs @@ -4,6 +4,7 @@ using JWT.Serializers; using static JWT.Internal.EncodingHelper; +using static JWT.Serializers.JsonSerializerFactory; namespace JWT.Builder { diff --git a/src/JWT/Properties/AssemblyInfo.cs b/src/JWT/Properties/AssemblyInfo.cs index 369a697ae..5d13524ab 100644 --- a/src/JWT/Properties/AssemblyInfo.cs +++ b/src/JWT/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ using JWT; [assembly: InternalsVisibleTo("JWT.Tests.Common, PublicKey=" + AssemblyInfo.PublicKey)] -[assembly: InternalsVisibleTo("JWT.Tests.NetCore2, PublicKey=" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("JWT.Tests.NetCore3, PublicKey=" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("JWT.Tests.Net35, PublicKey=" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("JWT.Tests.Net40, PublicKey=" + AssemblyInfo.PublicKey)] diff --git a/tests/JWT.Tests.Common/Serializers/JsonSerializerFactory.cs b/src/JWT/Serializers/JsonSerializerFactory.cs similarity index 70% rename from tests/JWT.Tests.Common/Serializers/JsonSerializerFactory.cs rename to src/JWT/Serializers/JsonSerializerFactory.cs index 3a30ebfc5..884861603 100644 --- a/tests/JWT.Tests.Common/Serializers/JsonSerializerFactory.cs +++ b/src/JWT/Serializers/JsonSerializerFactory.cs @@ -1,6 +1,4 @@ -using JWT.Serializers; - -namespace JWT.Tests.Serializers +namespace JWT.Serializers { internal static class JsonSerializerFactory { @@ -11,7 +9,7 @@ public static IJsonSerializer CreateSerializer() #elif NEWTONSOFT_JSON return new JsonNetSerializer(); #else - throw new NotSupportedException(); + throw new System.NotSupportedException(); #endif } } diff --git a/tests/JWT.Extensions.AspNetCore.Tests/JwtAuthenticationHandlerTests.cs b/tests/JWT.Extensions.AspNetCore.Tests/JwtAuthenticationHandlerTests.cs index 186b7d209..068b75252 100644 --- a/tests/JWT.Extensions.AspNetCore.Tests/JwtAuthenticationHandlerTests.cs +++ b/tests/JWT.Extensions.AspNetCore.Tests/JwtAuthenticationHandlerTests.cs @@ -13,7 +13,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -using static JWT.Tests.Serializers.JsonSerealizerFactory; +using static JWT.Serializers.JsonSerializerFactory; namespace JWT.Extensions.AspNetCore.Tests { diff --git a/tests/JWT.Tests.Common/JwtDecoderTests.cs b/tests/JWT.Tests.Common/JwtDecoderTests.cs index 8d175f4cc..26a69b8a4 100644 --- a/tests/JWT.Tests.Common/JwtDecoderTests.cs +++ b/tests/JWT.Tests.Common/JwtDecoderTests.cs @@ -5,11 +5,12 @@ using JWT.Algorithms; using JWT.Builder; using JWT.Exceptions; -using JWT.Serializers; using JWT.Tests.Models; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; +using static JWT.Serializers.JsonSerializerFactory; + namespace JWT.Tests { [TestClass] @@ -547,16 +548,5 @@ public void DecodeToObject_Should_Throw_Exception_On_Null_NotBefore_Claim() .Throw() .WithMessage("Claim 'nbf' must be a number.", "because the invalid 'nbf' must result in an exception on decoding"); } - - private static IJsonSerializer CreateSerializer() - { -#if SYSTEM_TEXT_JSON - return new SystemTextSerializer(); -#elif NEWTONSOFT_JSON - return new JsonNetSerializer(); -#else - throw new NotSupportedException(); -#endif - } } } \ No newline at end of file diff --git a/tests/JWT.Tests.Common/JwtEncoderTests.cs b/tests/JWT.Tests.Common/JwtEncoderTests.cs index 3c60fed42..a3ee9d892 100644 --- a/tests/JWT.Tests.Common/JwtEncoderTests.cs +++ b/tests/JWT.Tests.Common/JwtEncoderTests.cs @@ -1,10 +1,11 @@ using System.Collections.Generic; using FluentAssertions; using JWT.Algorithms; -using JWT.Serializers; using JWT.Tests.Models; using Microsoft.VisualStudio.TestTools.UnitTesting; +using static JWT.Serializers.JsonSerializerFactory; + namespace JWT.Tests { [TestClass] @@ -89,16 +90,5 @@ public void Encode_With_NoAlgorithm_Should_Encode_To_Token() actual.Should() .Be(expected, "because the same data encoded with the same key must result in the same token"); } - - private static IJsonSerializer CreateSerializer() - { -#if SYSTEM_TEXT_JSON - return new SystemTextSerializer(); -#elif NEWTONSOFT_JSON - return new JsonNetSerializer(); -#else - throw new NotSupportedException(); -#endif - } } } \ No newline at end of file diff --git a/tests/JWT.Tests.Common/JwtSecurityTests.cs b/tests/JWT.Tests.Common/JwtSecurityTests.cs index d8e446f7f..e793ba5d9 100644 --- a/tests/JWT.Tests.Common/JwtSecurityTests.cs +++ b/tests/JWT.Tests.Common/JwtSecurityTests.cs @@ -3,10 +3,11 @@ using AutoFixture; using FluentAssertions; using JWT.Algorithms; -using JWT.Serializers; using JWT.Tests.Models; using Microsoft.VisualStudio.TestTools.UnitTesting; +using static JWT.Serializers.JsonSerializerFactory; + namespace JWT.Tests { [TestClass] @@ -96,16 +97,5 @@ public void Decode_Should_Throw_Exception_When_Jwt_Contains_HMA_Algorithm_But_RS action.Should() .Throw("because an encryption algorithm can't be changed on decoding"); } - - private static IJsonSerializer CreateSerializer() - { -#if SYSTEM_TEXT_JSON - return new SystemTextSerializer(); -#elif NEWTONSOFT_JSON - return new JsonNetSerializer(); -#else - throw new NotSupportedException(); -#endif - } } } \ No newline at end of file diff --git a/tests/JWT.Tests.Common/JwtValidatorTests.cs b/tests/JWT.Tests.Common/JwtValidatorTests.cs index bd407f808..48843fb84 100644 --- a/tests/JWT.Tests.Common/JwtValidatorTests.cs +++ b/tests/JWT.Tests.Common/JwtValidatorTests.cs @@ -2,11 +2,12 @@ using FluentAssertions; using JWT.Algorithms; using JWT.Exceptions; -using JWT.Serializers; using JWT.Tests.Models; using JWT.Tests.Stubs; using Microsoft.VisualStudio.TestTools.UnitTesting; + using static JWT.Internal.EncodingHelper; +using static JWT.Serializers.JsonSerializerFactory; namespace JWT.Tests { diff --git a/tests/JWT.Tests.Net60/JWT.Tests.Net60.csproj b/tests/JWT.Tests.Net60/JWT.Tests.Net60.csproj index c966f71d6..13a301612 100644 --- a/tests/JWT.Tests.Net60/JWT.Tests.Net60.csproj +++ b/tests/JWT.Tests.Net60/JWT.Tests.Net60.csproj @@ -2,7 +2,6 @@ net6.0 - .NETFramework,Version=6.0