コード例 #1
0
        public void FromJson_CorrectJsonClass()
        {
            //arrange
            var json      = ExpectedJson;
            var jsonClass = new JsonNamedPropertyClass();

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

            //assert
            Assert.That(jsonClass.Age, Is.EqualTo(42));
            Assert.That(jsonClass.Height, Is.EqualTo(176));
            Assert.That(jsonClass.Escaping, Is.EqualTo(12));
        }
コード例 #2
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonNamedPropertyClass()
            {
                Age      = 42,
                Height   = 176,
                Escaping = 12,
            };

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

            //assert
            Assert.That(json.ToString(), Is.EqualTo(ExpectedJson));
        }
コード例 #3
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonNamedPropertyClass()
            {
                Age      = 42,
                Height   = 176,
                Escaping = 12,
            };

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

            //assert
            System.Console.WriteLine("JSON: " + new string(json));
            Assert.That(json, Is.EqualTo(ExpectedJson));
        }
コード例 #4
0
 protected abstract ReadOnlySpan <char> FromJson(JsonNamedPropertyClass value, string json);
コード例 #5
0
 protected abstract string ToJson(JsonNamedPropertyClass jsonClass);
コード例 #6
0
 protected override ReadOnlySpan <char> FromJson(JsonNamedPropertyClass value, string json)
 {
     return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json))));
 }
コード例 #7
0
        protected override string ToJson(JsonNamedPropertyClass jsonClass)
        {
            var jsonUtf8 = _convert.ToJsonUtf8(jsonClass);

            return(Encoding.UTF8.GetString(jsonUtf8));
        }
コード例 #8
0
 protected override ReadOnlySpan <char> FromJson(JsonNamedPropertyClass value, string json)
 {
     return(_convert.FromJson(value, json));
 }
コード例 #9
0
 protected override string ToJson(JsonNamedPropertyClass jsonClass)
 {
     return(_convert.ToJson(jsonClass).ToString());
 }