Fix tests for the object extension manager.

pull/3831/head
Halil İbrahim Kalkan 5 years ago
parent 41b6c7337a
commit 8a31febcb5

@ -34,10 +34,10 @@ namespace AutoMapper
personDto.GetProperty<string>("Name").ShouldBe("John"); //Defined in both classes
personDto.GetProperty<string>("ExistingDtoProperty").ShouldBe("existing-value"); //Should not clear existing values
personDto.GetProperty<int>("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
}
}
}

@ -23,7 +23,7 @@ namespace Volo.Abp.ObjectExtending
.AddOrUpdateProperty<ExtensibleTestPerson, string>("CityName")
.AddOrUpdateProperty<ExtensibleTestPersonDto, string>("Name")
.AddOrUpdateProperty<ExtensibleTestPersonDto, int>("ChildCount")
.AddOrUpdateProperty<ExtensibleTestPersonDto, int>("CityName");
.AddOrUpdateProperty<ExtensibleTestPersonDto, string>("CityName");
});
}
}

@ -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'!
}

@ -34,7 +34,7 @@ namespace Volo.Abp.ObjectExtending
_personDto.GetProperty<string>("NoPairCheck").ShouldBe("test-value"); //CheckPairDefinitionOnMapping = false
_personDto.GetProperty<string>("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<int>("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<string>("Name").ShouldBe("John"); //Defined in both classes
_personDto.GetProperty<string>("NoPairCheck").ShouldBe("test-value"); //CheckPairDefinitionOnMapping = false
_personDto.GetProperty<string>("ExistingDtoProperty").ShouldBe("existing-value"); //Should not clear existing values
_personDto.HasProperty("CityName").ShouldBeFalse(); //Ignored!
_personDto.GetProperty<string>("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<int>("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<string>("CityName").ShouldBe("Adana"); //Defined in both classes
_personDto.GetProperty<int>("Age").ShouldBe(42); //Defined in source
_personDto.GetProperty<string>("ExistingDtoProperty").ShouldBe("existing-value"); //Should not clear existing values
_personDto.HasProperty("ChildCount").ShouldBeFalse(); //Not defined in the source
_personDto.GetProperty<int>("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
}

Loading…
Cancel
Save