Skip to content

Commit

Permalink
JsonSerializerFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
abatishchev committed Apr 11, 2022
1 parent 6cff38e commit 7f3785b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 44 deletions.
1 change: 1 addition & 0 deletions src/JWT/Builder/JwtBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using JWT.Serializers;

using static JWT.Internal.EncodingHelper;
using static JWT.Serializers.JsonSerializerFactory;

namespace JWT.Builder
{
Expand Down
1 change: 0 additions & 1 deletion src/JWT/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using JWT.Serializers;

namespace JWT.Tests.Serializers
namespace JWT.Serializers
{
internal static class JsonSerializerFactory
{
Expand All @@ -11,7 +9,7 @@ public static IJsonSerializer CreateSerializer()
#elif NEWTONSOFT_JSON
return new JsonNetSerializer();
#else
throw new NotSupportedException();
throw new System.NotSupportedException();
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
14 changes: 2 additions & 12 deletions tests/JWT.Tests.Common/JwtDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -547,16 +548,5 @@ public void DecodeToObject_Should_Throw_Exception_On_Null_NotBefore_Claim()
.Throw<SignatureVerificationException>()
.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
}
}
}
14 changes: 2 additions & 12 deletions tests/JWT.Tests.Common/JwtEncoderTests.cs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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
}
}
}
14 changes: 2 additions & 12 deletions tests/JWT.Tests.Common/JwtSecurityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -96,16 +97,5 @@ public void Decode_Should_Throw_Exception_When_Jwt_Contains_HMA_Algorithm_But_RS
action.Should()
.Throw<NotSupportedException>("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
}
}
}
3 changes: 2 additions & 1 deletion tests/JWT.Tests.Common/JwtValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
1 change: 0 additions & 1 deletion tests/JWT.Tests.Net60/JWT.Tests.Net60.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworkIdentifier>.NETFramework,Version=6.0</TargetFrameworkIdentifier>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 7f3785b

Please sign in to comment.