mirror of https://github.com/abpframework/abp.git
10 changed files with 68 additions and 11 deletions
@ -1,9 +1,32 @@ |
|||||
using Volo.Abp.TestApp.Testing; |
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.TestApp.Testing; |
||||
|
using Xunit; |
||||
|
|
||||
namespace Volo.Abp.EntityFrameworkCore.Domain |
namespace Volo.Abp.EntityFrameworkCore.Domain |
||||
{ |
{ |
||||
public class ExtraProperties_Tests : ExtraProperties_Tests<AbpEntityFrameworkCoreTestModule> |
public class ExtraProperties_Tests : ExtraProperties_Tests<AbpEntityFrameworkCoreTestModule> |
||||
{ |
{ |
||||
|
[Fact] |
||||
|
public async Task Should_Get_An_Extra_Property_Configured_As_Extension() |
||||
|
{ |
||||
|
var london = await CityRepository.FindByNameAsync("London"); |
||||
|
london.HasProperty("PhoneCode").ShouldBeTrue(); |
||||
|
london.GetProperty<string>("PhoneCode").ShouldBe("42"); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task Should_Update_An_Existing_Extra_Property_Configured_As_Extension() |
||||
|
{ |
||||
|
var london = await CityRepository.FindByNameAsync("London"); |
||||
|
london.GetProperty<string>("PhoneCode").ShouldBe("42"); |
||||
|
|
||||
|
london.ExtraProperties["PhoneCode"] = "53"; |
||||
|
await CityRepository.UpdateAsync(london); |
||||
|
|
||||
|
var london2 = await CityRepository.FindByNameAsync("London"); |
||||
|
london2.GetProperty<string>("PhoneCode").ShouldBe("53"); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,22 @@ |
|||||
|
using Volo.Abp.EntityFrameworkCore.Extensions; |
||||
|
using Volo.Abp.TestApp.Domain; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace Volo.Abp.EntityFrameworkCore.Domain |
||||
|
{ |
||||
|
public static class TestEntityExtensionConfigurator |
||||
|
{ |
||||
|
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
||||
|
|
||||
|
public static void Configure() |
||||
|
{ |
||||
|
OneTimeRunner.Run(() => |
||||
|
{ |
||||
|
EntityExtensionManager.AddProperty<City, string>( |
||||
|
"PhoneCode", |
||||
|
p => p.HasMaxLength(8) |
||||
|
); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue