예제 #1
0
        public void FromJson_CorrectJsonClass()
        {
            //arrange
            var json      = ExpectedJson;
            var jsonClass = new JsonULongClass();

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

            //assert
            Assert.That(jsonClass.Age, Is.EqualTo(42));
            Assert.That(jsonClass.Height, Is.EqualTo(176));
            Assert.That(jsonClass.Min, Is.EqualTo(ulong.MinValue));
            Assert.That(jsonClass.Max, Is.EqualTo(ulong.MaxValue));
        }
예제 #2
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonULongClass()
            {
                Age    = 42,
                Height = 176,
                Max    = ulong.MaxValue,
                Min    = ulong.MinValue
            };

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

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

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