From 6404c02764647acc445dcec6395602d040e3cf70 Mon Sep 17 00:00:00 2001 From: maliming Date: Sat, 14 Nov 2020 13:04:14 +0800 Subject: [PATCH] Fix unit test. --- ...pSystemTextJsonSerializerProvider_Tests.cs | 115 +++++++++--------- 1 file changed, 59 insertions(+), 56 deletions(-) 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 3c32a99dec..9e166aa146 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 @@ -8,15 +8,71 @@ using Xunit; namespace Volo.Abp.Json { - public class AbpSystemTextJsonSerializerProvider_Tests : AbpJsonTestBase + public abstract class AbpSystemTextJsonSerializerProvider_TestBase : AbpJsonTestBase { protected AbpSystemTextJsonSerializerProvider JsonSerializer; - public AbpSystemTextJsonSerializerProvider_Tests() + public AbpSystemTextJsonSerializerProvider_TestBase() { JsonSerializer = GetRequiredService(); } + public class TestExtensibleObjectClass : ExtensibleObject + { + public string Name { get; set; } + } + + public class FileWithBoolean + { + public string Name { get; set; } + + public bool IsDeleted { get; set; } + } + + public class FileWithNullableBoolean + { + public string Name { get; set; } + + public bool? IsDeleted { get; set; } + } + + public class FileWithEnum + { + public string Name { get; set; } + + public FileType Type { get; set; } + } + + public class FileWithNullableEnum + { + public string Name { get; set; } + + public FileType? Type { get; set; } + } + + public enum FileType + { + Zip = 0, + Exe = 2 + } + + public class FileWithDatetime + { + public string Name { get; set; } + + public DateTime CreationTime { get; set; } + } + + public class FileWithNullableDatetime + { + public string Name { get; set; } + + public DateTime? CreationTime { get; set; } + } + } + + public class AbpSystemTextJsonSerializerProvider_Tests : AbpSystemTextJsonSerializerProvider_TestBase + { [Fact] public void Serialize_Deserialize_With_Boolean() { @@ -132,62 +188,9 @@ namespace Volo.Abp.Json file.CreationTime.Value.Month.ShouldBe(11); file.CreationTime.Value.Day.ShouldBe(20); } - - class TestExtensibleObjectClass : ExtensibleObject - { - public string Name { get; set; } - } - - class FileWithBoolean - { - public string Name { get; set; } - - public bool IsDeleted { get; set; } - } - - class FileWithNullableBoolean - { - public string Name { get; set; } - - public bool? IsDeleted { get; set; } - } - - class FileWithEnum - { - public string Name { get; set; } - - public FileType Type { get; set; } - } - - class FileWithNullableEnum - { - public string Name { get; set; } - - public FileType? Type { get; set; } - } - - enum FileType - { - Zip = 0, - Exe = 2 - } - - protected class FileWithDatetime - { - public string Name { get; set; } - - public DateTime CreationTime { get; set; } - } - - protected class FileWithNullableDatetime - { - public string Name { get; set; } - - public DateTime? CreationTime { get; set; } - } } - public class FormatAbpSystemTextJsonSerializerProvider_Tests : AbpSystemTextJsonSerializerProvider_Tests + public class AbpSystemTextJsonSerializerProviderDefaultDateTimeFormat_Tests : AbpSystemTextJsonSerializerProvider_TestBase { protected override void AfterAddApplication(IServiceCollection services) {