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

            //act
            FromJson(jsonDec, json);

            //assert
            Assert.That(jsonDec.DecNull, Is.Null);
            Assert.That(jsonDec.Value2, Is.EqualTo(1.5m));
            Assert.That(jsonDec.Value, Is.EqualTo(-200000.01m));
            Assert.That(jsonDec.Min, Is.EqualTo(MIN));
        }
Esempio n. 2
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonDec = new JsonDecimal()
            {
                DecNull = null,
                Min     = MIN,
                Value   = -200000.01m,
                Value2  = 1.5m,
            };

            //act
            var json = ToJson(jsonDec);

            //assert
            Assert.That(json.ToString(), Is.EqualTo(ExpectedJson));
        }
Esempio n. 3
0
        public void FromJson_CorrectJsonClass_PT_BR()
        {
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("pt-BR");
            Thread.CurrentThread.CurrentCulture   = Thread.CurrentThread.CurrentUICulture;

            //arrange
            var json    = ExpectedJson_PT_BR;
            var jsonDec = new JsonDecimal();

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

            //assert
            Assert.That(jsonDec.DecNull, Is.Null);
            Assert.That(jsonDec.Value, Is.EqualTo(-200000.01m));
            Assert.That(jsonDec.Value2, Is.EqualTo(1.5m));
            Assert.That(jsonDec.Min, Is.EqualTo(MIN));
        }
Esempio n. 4
0
        public void ToJson_CorrectString_EN_US()
        {
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-us");
            Thread.CurrentThread.CurrentCulture   = Thread.CurrentThread.CurrentUICulture;

            //arrange
            var jsonDec = new JsonDecimal()
            {
                DecNull = null,
                Min     = MIN,
                Value   = -200000.01m,
                Value2  = 1.5m,
            };

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

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

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