diff --git a/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs b/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs index d0ee7db52d..4ec19bb84e 100644 --- a/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs +++ b/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs @@ -34,10 +34,10 @@ namespace AutoMapper personDto.GetProperty("Name").ShouldBe("John"); //Defined in both classes personDto.GetProperty("ExistingDtoProperty").ShouldBe("existing-value"); //Should not clear existing values + personDto.GetProperty("ChildCount").ShouldBe(0); //Not defined in the source, but was set to the default value by ExtensibleTestPersonDto constructor + personDto.GetProperty("CityName").ShouldBeNull(); //Ignored, but was set to the default value by ExtensibleTestPersonDto constructor personDto.HasProperty("Age").ShouldBeFalse(); //Not defined on the destination - personDto.HasProperty("ChildCount").ShouldBeFalse(); //Not defined in the source personDto.HasProperty("Sex").ShouldBeFalse(); //Not defined in both classes - personDto.HasProperty("CityName").ShouldBeFalse(); //Ignored } } } diff --git a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/AbpObjectExtendingTestModule.cs b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/AbpObjectExtendingTestModule.cs index 3eff9846f7..ba7091befa 100644 --- a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/AbpObjectExtendingTestModule.cs +++ b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/AbpObjectExtendingTestModule.cs @@ -23,7 +23,7 @@ namespace Volo.Abp.ObjectExtending .AddOrUpdateProperty("CityName") .AddOrUpdateProperty("Name") .AddOrUpdateProperty("ChildCount") - .AddOrUpdateProperty("CityName"); + .AddOrUpdateProperty("CityName"); }); } } diff --git a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/ExtensibleObjectValidator_Tests.cs b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/ExtensibleObjectValidator_Tests.cs index 8c27844e22..83ecc3100f 100644 --- a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/ExtensibleObjectValidator_Tests.cs +++ b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/ExtensibleObjectValidator_Tests.cs @@ -55,7 +55,7 @@ namespace Volo.Abp.ObjectExtending context.ValidationErrors.Add( new ValidationResult( "If you specify a password, then please correctly repeat it!", - new[] {"Password", "PasswordRepeat"} + new[] { "Password", "PasswordRepeat" } ) ); } @@ -84,14 +84,9 @@ namespace Volo.Abp.ObjectExtending { ExtensibleObjectValidator .GetValidationErrors( - new ExtensiblePersonObject - { - ExtraProperties = - { - {"Name", "John"}, - {"Age", "42"}, - } - } + new ExtensiblePersonObject() + .SetProperty("Name", "John") + .SetProperty("Age", 42) ).Count.ShouldBe(0); //All Valid } @@ -105,62 +100,37 @@ namespace Volo.Abp.ObjectExtending ExtensibleObjectValidator .GetValidationErrors( - new ExtensiblePersonObject - { - ExtraProperties = - { - {"Address", new string('x', 256) } - } - } + new ExtensiblePersonObject() + .SetProperty("Address", new string('x', 256)) ).Count.ShouldBe(3); // Name, Age & Address ExtensibleObjectValidator .GetValidationErrors( - new ExtensiblePersonObject - { - ExtraProperties = - { - {"Age", "42" } - } - } + new ExtensiblePersonObject() + .SetProperty("Age", 42) ).Count.ShouldBe(1); // Name ExtensibleObjectValidator .GetValidationErrors( - new ExtensiblePersonObject - { - ExtraProperties = - { - {"Address", new string('x', 256) }, - {"Age", "100" } - } - } + new ExtensiblePersonObject() + .SetProperty("Address", new string('x', 256)) + .SetProperty("Age", 100) ).Count.ShouldBe(3); // Name, Age & Address ExtensibleObjectValidator .GetValidationErrors( - new ExtensiblePersonObject - { - ExtraProperties = - { - {"Name", "John"}, - {"Age", "42"}, - {"Password", "123"}, - {"PasswordRepeat", "1256"} - } - } + new ExtensiblePersonObject() + .SetProperty("Name", "John") + .SetProperty("Age", 42) + .SetProperty("Password", "123") + .SetProperty("PasswordRepeat", "1256") ).Count.ShouldBe(1); // PasswordRepeat != Password ExtensibleObjectValidator .GetValidationErrors( - new ExtensiblePersonObject - { - ExtraProperties = - { - {"Name", "BadValue"}, - {"Age", "42"}, - } - } + new ExtensiblePersonObject() + .SetProperty("Name", "BadValue") + .SetProperty("Age", 42) ).Count.ShouldBe(1); //Name is 'BadValue'! } diff --git a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions_Tests.cs b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions_Tests.cs index e871aeb056..5d019daf48 100644 --- a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions_Tests.cs +++ b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions_Tests.cs @@ -34,7 +34,7 @@ namespace Volo.Abp.ObjectExtending _personDto.GetProperty("NoPairCheck").ShouldBe("test-value"); //CheckPairDefinitionOnMapping = false _personDto.GetProperty("ExistingDtoProperty").ShouldBe("existing-value"); //Should not clear existing values _personDto.HasProperty("Age").ShouldBeFalse(); //Not defined on the destination - _personDto.HasProperty("ChildCount").ShouldBeFalse(); //Not defined in the source + _personDto.GetProperty("ChildCount").ShouldBe(0); //Not defined in the source, but was set to the default in the constructor _personDto.HasProperty("Sex").ShouldBeFalse(); //Not defined in both classes } @@ -46,9 +46,9 @@ namespace Volo.Abp.ObjectExtending _personDto.GetProperty("Name").ShouldBe("John"); //Defined in both classes _personDto.GetProperty("NoPairCheck").ShouldBe("test-value"); //CheckPairDefinitionOnMapping = false _personDto.GetProperty("ExistingDtoProperty").ShouldBe("existing-value"); //Should not clear existing values - _personDto.HasProperty("CityName").ShouldBeFalse(); //Ignored! + _personDto.GetProperty("CityName").ShouldBeNull(); //Ignored, but was set to the default in the constructor _personDto.HasProperty("Age").ShouldBeFalse(); //Not defined on the destination - _personDto.HasProperty("ChildCount").ShouldBeFalse(); //Not defined in the source + _personDto.GetProperty("ChildCount").ShouldBe(0); //Not defined in the source, but was set to the default in the constructor _personDto.HasProperty("Sex").ShouldBeFalse(); //Not defined in both classes } @@ -61,7 +61,7 @@ namespace Volo.Abp.ObjectExtending _personDto.GetProperty("CityName").ShouldBe("Adana"); //Defined in both classes _personDto.GetProperty("Age").ShouldBe(42); //Defined in source _personDto.GetProperty("ExistingDtoProperty").ShouldBe("existing-value"); //Should not clear existing values - _personDto.HasProperty("ChildCount").ShouldBeFalse(); //Not defined in the source + _personDto.GetProperty("ChildCount").ShouldBe(0); //Not defined in the source, but was set to the default in the constructor _personDto.HasProperty("Sex").ShouldBeFalse(); //Not defined in both classes }