diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpJsonSystemTextJsonTestBase.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpJsonSystemTextJsonTestBase.cs index ebae706aca..e442ce48ad 100644 --- a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpJsonSystemTextJsonTestBase.cs +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpJsonSystemTextJsonTestBase.cs @@ -1,4 +1,9 @@ -using Volo.Abp.Testing; +using System; +using System.Collections.Concurrent; +using System.Reflection; +using Newtonsoft.Json; +using Volo.Abp.Json.Newtonsoft; +using Volo.Abp.Testing; namespace Volo.Abp.Json; @@ -12,6 +17,16 @@ public abstract class AbpJsonSystemTextJsonTestBase : AbpIntegratedTest { + protected AbpJsonNewtonsoftJsonTestBase() + { + var cache = typeof(AbpNewtonsoftJsonSerializer).GetField("JsonSerializerOptionsCache", BindingFlags.NonPublic | BindingFlags.Static); + if (cache != null) + { + var cacheValue = cache.GetValue(null)?.As>(); + cacheValue?.Clear(); + } + } + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) { options.UseAutofac(); diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpNewtonsoftSerializerProviderTests.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpNewtonsoftSerializerProviderTests.cs index 74a639904d..9dc0c0afd3 100644 --- a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpNewtonsoftSerializerProviderTests.cs +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpNewtonsoftSerializerProviderTests.cs @@ -1,18 +1,18 @@ using System; using System.Collections.Generic; using Shouldly; -using Volo.Abp.Json.Newtonsoft; using Xunit; namespace Volo.Abp.Json; +[Collection("AbpJsonNewtonsoftJsonTest")] public class AbpNewtonsoftSerializerProviderTests : AbpJsonNewtonsoftJsonTestBase { - protected AbpNewtonsoftJsonSerializer JsonSerializer; + protected IJsonSerializer JsonSerializer; public AbpNewtonsoftSerializerProviderTests() { - JsonSerializer = GetRequiredService(); + JsonSerializer = GetRequiredService(); } public class File diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpSystemTextJsonSerializerProvider_Tests.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpSystemTextJsonSerializerProvider_Tests.cs index a492b7ad7c..49b321d46d 100644 --- a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpSystemTextJsonSerializerProvider_Tests.cs +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpSystemTextJsonSerializerProvider_Tests.cs @@ -13,11 +13,11 @@ namespace Volo.Abp.Json; public abstract class AbpSystemTextJsonSerializerProviderTestBase : AbpJsonSystemTextJsonTestBase { - protected AbpSystemTextJsonSerializer JsonSerializer; + protected IJsonSerializer JsonSerializer; public AbpSystemTextJsonSerializerProviderTestBase() { - JsonSerializer = GetRequiredService(); + JsonSerializer = GetRequiredService(); } public class TestExtensibleObjectClass : ExtensibleObject @@ -260,6 +260,8 @@ public class AbpSystemTextJsonSerializerProviderDateTimeFormatTests : AbpSystemT options.InputDateTimeFormats.Add("yyyy*MM*dd"); options.OutputDateTimeFormat = "yyyy*MM*dd HH*mm*ss"; }); + + base.AfterAddApplication(services); } [Fact] @@ -326,6 +328,8 @@ public class AbpSystemTextJsonSerializerProviderDatetimeKindUtcTests : AbpSystem { Kind = DateTimeKind.Utc; services.Configure(x => x.Kind = Kind); + + base.AfterAddApplication(services); } } @@ -335,6 +339,8 @@ public class AbpSystemTextJsonSerializerProviderDatetimeKindLocalTests : AbpSyst { Kind = DateTimeKind.Local; services.Configure(x => x.Kind = Kind); + + base.AfterAddApplication(services); } } diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/InputAndOutputDateTimeFormat_Tests.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/InputAndOutputDateTimeFormat_Tests.cs index cf6356477d..189a82cae0 100644 --- a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/InputAndOutputDateTimeFormat_Tests.cs +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/InputAndOutputDateTimeFormat_Tests.cs @@ -31,6 +31,8 @@ public class InputAndOutputDateTimeFormatSystemTextJsonTests : AbpJsonSystemText { options.Kind = DateTimeKind.Utc; }); + + base.AfterAddApplication(services); } [Fact] @@ -59,6 +61,7 @@ public class InputAndOutputDateTimeFormatSystemTextJsonTests : AbpJsonSystemText } } +[Collection("AbpJsonNewtonsoftJsonTest")] public class InputAndOutputDateTimeFormatNewtonsoftTests : AbpJsonNewtonsoftJsonTestBase { private readonly IJsonSerializer _jsonSerializer; @@ -83,6 +86,8 @@ public class InputAndOutputDateTimeFormatNewtonsoftTests : AbpJsonNewtonsoftJson { options.Kind = DateTimeKind.Utc; }); + + base.AfterAddApplication(services); } [Fact]