예제 #1
0
        public void FromJson_CorrectJsonClass(char expectedCharacter, string property)
        {
            //arrange
            var json      = $"{{\"Property\":{property}}}";
            var jsonClass = new JsonCharClass();

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

            //assert
            Assert.That(jsonClass.Property, Is.EqualTo(expectedCharacter));
        }
예제 #2
0
        public void FromJson_EscapedUnicode_CorrectJsonClass()
        {
            //arrange
            var json      = "{\"Property\":\"\\u1F4A\"}";
            var jsonClass = new JsonCharClass();

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

            //assert
            Assert.That(jsonClass.Property, Is.EqualTo('\u1F4A'));
        }
예제 #3
0
        public void ToJson_CorrectString(char character, string expectedPropertyValue)
        {
            //arrange
            var jsonClass = new JsonCharClass()
            {
                Property = character
            };

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

            //assert
            Assert.That(json.ToString(), Is.EqualTo($"{{\"Property\":{expectedPropertyValue}}}"));
        }
예제 #4
0
 protected abstract string ToJson(JsonCharClass jsonClass);
예제 #5
0
 protected override ReadOnlySpan <char> FromJson(JsonCharClass value, string json)
 {
     return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json))));
 }
예제 #6
0
        protected override string ToJson(JsonCharClass jsonClass)
        {
            var jsonUtf8 = _convert.ToJsonUtf8(jsonClass);

            return(Encoding.UTF8.GetString(jsonUtf8));
        }
예제 #7
0
 protected override ReadOnlySpan <char> FromJson(JsonCharClass value, string json)
 {
     return(_convert.FromJson(value, json));
 }
예제 #8
0
 protected override string ToJson(JsonCharClass jsonClass)
 {
     return(_convert.ToJson(jsonClass).ToString());
 }
예제 #9
0
 protected abstract ReadOnlySpan <char> FromJson(JsonCharClass value, string json);