Esempio n. 1
0
        public void FromJson_CorrectJsonClass()
        {
            //arrange
            var json      = ExpectedJson;
            var jsonClass = new JsonByteClass();

            //act
            FromJson(jsonClass, json);

            //assert
            Assert.That(jsonClass.Age, Is.EqualTo(42));
            Assert.That(jsonClass.Height, Is.EqualTo(176));
            Assert.That(jsonClass.Min, Is.EqualTo(byte.MinValue));
            Assert.That(jsonClass.Max, Is.EqualTo(byte.MaxValue));
        }
Esempio n. 2
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonByteClass()
            {
                Age    = 42,
                Height = 176,
                Max    = byte.MaxValue,
                Min    = byte.MinValue
            };

            //act
            var json = ToJson(jsonClass);

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

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