mirror of https://github.com/abpframework/abp.git
4 changed files with 81 additions and 1 deletions
@ -0,0 +1,29 @@ |
|||||
|
using System; |
||||
|
using Newtonsoft.Json; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Validation.StringValues; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement |
||||
|
{ |
||||
|
public class StringValueTypeJsonConverter : JsonConverter, ITransientDependency |
||||
|
{ |
||||
|
public override bool CanWrite => false; |
||||
|
|
||||
|
public override bool CanConvert(Type objectType) |
||||
|
{ |
||||
|
return objectType == typeof(IStringValueType); |
||||
|
} |
||||
|
|
||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) |
||||
|
{ |
||||
|
throw new NotImplementedException("This method should not be called to write (since CanWrite is false)."); |
||||
|
} |
||||
|
|
||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) |
||||
|
{ |
||||
|
//TODO: Deserialize!
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Newtonsoft.Json; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Json; |
||||
|
using Volo.Abp.Validation.StringValues; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement |
||||
|
{ |
||||
|
public class StringValueJsonConverter_Tests : FeatureManagementApplicationTestBase |
||||
|
{ |
||||
|
private readonly IJsonSerializer _jsonSerializer; |
||||
|
|
||||
|
public StringValueJsonConverter_Tests() |
||||
|
{ |
||||
|
_jsonSerializer = GetRequiredService<IJsonSerializer>(); |
||||
|
} |
||||
|
|
||||
|
[Fact(Skip = "StringValueTypeJsonConverter is not implemented yet!")] |
||||
|
public void Should_Serialize_And_Deserialize() |
||||
|
{ |
||||
|
var featureListDto = new FeatureListDto |
||||
|
{ |
||||
|
Features = new List<FeatureDto> |
||||
|
{ |
||||
|
new FeatureDto |
||||
|
{ |
||||
|
ValueType = new FreeTextStringValueType |
||||
|
{ |
||||
|
Validator = new BooleanValueValidator() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//TODO: Add more to test
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
var serialized = _jsonSerializer.Serialize(featureListDto); |
||||
|
|
||||
|
var featureListDto2 = _jsonSerializer.Deserialize<FeatureListDto>(serialized); |
||||
|
|
||||
|
featureListDto2.Features[0].ValueType.ShouldBeOfType<FreeTextStringValueType>(); |
||||
|
featureListDto2.Features[0].ValueType.Validator.ShouldBeOfType<BooleanValueValidator>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue