Пример #1
0
        public void FromJson_CorrectJsonClass()
        {
            //arrange
            var json      = ExpectedJson;
            var jsonClass = new JsonDoubleClass();

            //act
            FromJson(jsonClass, json);

            //assert
            Assert.That(jsonClass.Age, Is.EqualTo(42.21d));
            Assert.That(jsonClass.Height, Is.EqualTo(176.568d));
            Assert.That(jsonClass.Min, Is.EqualTo(double.MinValue));
            Assert.That(jsonClass.Max, Is.EqualTo(double.MaxValue));
            Assert.That(jsonClass.Zero, Is.EqualTo(0));
        }
Пример #2
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonDoubleClass()
            {
                Age    = 42.21d,
                Height = 176.568d,
                Max    = double.MaxValue,
                Min    = double.MinValue,
                Zero   = 0
            };

            //act
            var json = ToJson(jsonClass);

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

            return(Encoding.UTF8.GetString(jsonUtf8));
        }
Пример #7
0
 protected override ReadOnlySpan <char> FromJson(JsonDoubleClass value, string json)
 {
     return(_convert.FromJson(value, json));
 }
Пример #8
0
 protected override string ToJson(JsonDoubleClass jsonClass)
 {
     return(_convert.ToJson(jsonClass).ToString());
 }