Exemplo n.º 1
0
        public void FromJson_CorrectJsonClass()
        {
            //arrange
            var json      = ExpectedJson;
            var jsonClass = new JsonIntClass();

            //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(int.MinValue));
            Assert.That(jsonClass.Max, Is.EqualTo(int.MaxValue));
            Assert.That(jsonClass.Zero, Is.EqualTo(0));
        }
Exemplo n.º 2
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonIntClass()
            {
                Age    = 42,
                Height = 176,
                Max    = int.MaxValue,
                Min    = int.MinValue,
                Zero   = 0
            };

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

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

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