You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/ExtensibleObject_Tests.cs

40 lines
1.4 KiB

using Shouldly;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending.TestObjects;
using Xunit;
namespace Volo.Abp.ObjectExtending;
public class ExtensibleObject_Tests : AbpObjectExtendingTestBase
{
[Fact]
public void Should_Set_Default_Values_For_Defined_Properties_On_Create()
{
var person = new ExtensibleTestPerson();
person.HasProperty("Name").ShouldBeTrue();
person.HasProperty("Age").ShouldBeTrue();
person.HasProperty("NoPairCheck").ShouldBeTrue();
person.HasProperty("CityName").ShouldBeTrue();
person.HasProperty("EnumProperty").ShouldBeTrue();
person.GetProperty<string>("Name").ShouldBeNull();
person.GetProperty<int>("Age").ShouldBe(0);
person.GetProperty<string>("NoPairCheck").ShouldBeNull();
person.GetProperty<string>("CityName").ShouldBeNull();
person.GetProperty<ExtensibleTestEnumProperty>("EnumProperty").ShouldBe(default);
}
[Fact]
public void Should_Not_Set_Default_Values_For_Defined_Properties_If_Requested()
{
var person = new ExtensibleTestPerson(false);
person.HasProperty("Name").ShouldBeFalse();
person.HasProperty("Age").ShouldBeFalse();
person.HasProperty("NoPairCheck").ShouldBeFalse();
person.HasProperty("CityName").ShouldBeFalse();
person.HasProperty("EnumProperty").ShouldBeFalse();
}
}