Exemple #1
0
        public void FromJson_CorrectJsonClass()
        {
            //arrange
            var json      = ExpectedJson;
            var jsonClass = new JsonShortClass();

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

            //act
            var json = ToJson(jsonClass);

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

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