diff --git a/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Domain/ExtraProperties_Tests.cs b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Domain/ExtraProperties_Tests.cs new file mode 100644 index 0000000000..eea827fbee --- /dev/null +++ b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Domain/ExtraProperties_Tests.cs @@ -0,0 +1,9 @@ +using Volo.Abp.TestApp.Testing; + +namespace Volo.Abp.EntityFrameworkCore.Domain +{ + public class ExtraProperties_Tests : ExtraProperties_Tests + { + + } +} diff --git a/framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Domain/ExtraProperties_Tests.cs b/framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Domain/ExtraProperties_Tests.cs new file mode 100644 index 0000000000..b389ad61b9 --- /dev/null +++ b/framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Domain/ExtraProperties_Tests.cs @@ -0,0 +1,9 @@ +using Volo.Abp.TestApp.Testing; + +namespace Volo.Abp.MongoDB.Domain +{ + public class ExtraProperties_Tests : ExtraProperties_Tests + { + + } +} diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestDataBuilder.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestDataBuilder.cs index f1bb42a344..25886f77a6 100644 --- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestDataBuilder.cs +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestDataBuilder.cs @@ -36,7 +36,7 @@ namespace Volo.Abp.TestApp { _cityRepository.Insert(new City(Guid.NewGuid(), "Tokyo")); _cityRepository.Insert(new City(Guid.NewGuid(), "Madrid")); - _cityRepository.Insert(new City(LondonCityId, "London")); + _cityRepository.Insert(new City(LondonCityId, "London") {ExtraProperties = { { "Population", 10_470_000 } } }); _cityRepository.Insert(new City(IstanbulCityId, "Istanbul")); _cityRepository.Insert(new City(Guid.NewGuid(), "Paris")); _cityRepository.Insert(new City(Guid.NewGuid(), "Washington")); diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/ExtraProperties_Tests.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/ExtraProperties_Tests.cs new file mode 100644 index 0000000000..adcad00e17 --- /dev/null +++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/ExtraProperties_Tests.cs @@ -0,0 +1,53 @@ +using System; +using System.Threading.Tasks; +using Shouldly; +using Volo.Abp.Modularity; +using Volo.Abp.TestApp.Domain; +using Xunit; + +namespace Volo.Abp.TestApp.Testing +{ + public abstract class ExtraProperties_Tests : TestAppTestBase + where TStartupModule : IAbpModule + { + protected readonly ICityRepository CityRepository; + + protected ExtraProperties_Tests() + { + CityRepository = GetRequiredService(); + } + + [Fact] + public async Task Should_Get_An_Extra_Property() + { + var london = await CityRepository.FindByNameAsync("London"); + london.ExtraProperties.ContainsKey("Population").ShouldBeTrue(); + london.ExtraProperties["Population"].To().ShouldBe(10_470_000); + } + + [Fact] + public async Task Should_Add_An_Extra_Property() + { + var london = await CityRepository.FindByNameAsync("London"); + london.ExtraProperties["AreaAsKm"] = 1572; + await CityRepository.UpdateAsync(london); + + var london2 = await CityRepository.FindByNameAsync("London"); + london2.ExtraProperties.ContainsKey("AreaAsKm").ShouldBeTrue(); + london2.ExtraProperties["AreaAsKm"].To().ShouldBe(1572); + } + + [Fact] + public async Task Should_Update_An_Existing_Extra_Property() + { + var london = await CityRepository.FindByNameAsync("London"); + + london.ExtraProperties["Population"] = 11_000_042; + await CityRepository.UpdateAsync(london); + + var london2 = await CityRepository.FindByNameAsync("London"); + london2.ExtraProperties.ContainsKey("Population").ShouldBeTrue(); + london2.ExtraProperties["Population"].To().ShouldBe(11_000_042); + } + } +}