Added HasExtraPropertiesExtensions.RemoveProperty and tests.

pull/848/head
Halil ibrahim Kalkan 7 years ago
parent 2c70fb780e
commit 2297033263

@ -39,5 +39,12 @@ namespace Volo.Abp.Data
source.ExtraProperties[name] = value;
return source;
}
public static TSource RemoveProperty<TSource>(this TSource source, string name)
where TSource : IHasExtraProperties
{
source.ExtraProperties.Remove(name);
return source;
}
}
}

@ -0,0 +1,33 @@
using System;
using Shouldly;
using Volo.Abp.Data;
using Volo.Abp.TestApp.Domain;
using Xunit;
namespace Volo.Abp.TestApp.Testing
{
public class HasExtraPropertiesExtensions_Tests
{
[Fact]
public void Basic_Tests()
{
var city = new City(Guid.NewGuid(), "Adana");
city.HasProperty("UnknownProperty").ShouldBeFalse();
city.GetProperty("UnknownProperty").ShouldBeNull();
city.GetProperty<int>("UnknownProperty").ShouldBe(0);
city.SetProperty("IsHot", true);
city.HasProperty("IsHot").ShouldBeTrue();
city.GetProperty<bool>("IsHot").ShouldBeTrue();
city.SetProperty("IsHot", false);
city.HasProperty("IsHot").ShouldBeTrue();
city.GetProperty<bool>("IsHot").ShouldBeFalse();
city.RemoveProperty("IsHot");
city.HasProperty("IsHot").ShouldBeFalse();
city.GetProperty<bool>("IsHot").ShouldBeFalse();
}
}
}
Loading…
Cancel
Save