public void FromJson_CorrectJsonClass()
        {
            //arrange
            var json      = ExpectedJson;
            var jsonClass = new JsonParentClass();

            //act
            _convert.FromJson(jsonClass, json);

            //assert
            Assert.That(jsonClass.Child.Name, Is.EqualTo("Samuel"));
            Assert.That(jsonClass.Child.Age, Is.EqualTo(8));
            Assert.That(jsonClass.Null, Is.Null);
        }
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonParentClass()
            {
                Child = new JsonChildClass()
                {
                    Name = "Samuel",
                    Age  = 8
                },
                Null = null,
            };

            //act
            var json = _convert.ToJson(jsonClass);

            //assert
            Assert.That(json, Is.EqualTo(ExpectedJson));
        }
示例#3
0
 protected abstract ReadOnlySpan <char> FromJson(JsonParentClass value, string json);
示例#4
0
 protected abstract string ToJson(JsonParentClass jsonClass);
示例#5
0
 protected override ReadOnlySpan <char> FromJson(JsonParentClass value, string json)
 {
     return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json))));
 }
示例#6
0
        protected override string ToJson(JsonParentClass jsonClass)
        {
            var jsonUtf8 = _convert.ToJsonUtf8(jsonClass);

            return(Encoding.UTF8.GetString(jsonUtf8));
        }
示例#7
0
 protected override ReadOnlySpan <char> FromJson(JsonParentClass value, string json)
 {
     return(_convert.FromJson(value, json));
 }
示例#8
0
 protected override string ToJson(JsonParentClass jsonClass)
 {
     return(_convert.ToJson(jsonClass).ToString());
 }