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)); }
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)); }
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)); }
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)); }
protected abstract ReadOnlySpan <char> FromJson(JsonDecimal value, string json);
protected abstract string ToJson(JsonDecimal jsonClass);
protected override ReadOnlySpan <char> FromJson(JsonDecimal value, string json) { return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json)))); }
protected override string ToJson(JsonDecimal jsonClass) { var jsonUtf8 = _convert.ToJsonUtf8(jsonClass); return(Encoding.UTF8.GetString(jsonUtf8)); }
protected override ReadOnlySpan <char> FromJson(JsonDecimal value, string json) { return(_convert.FromJson(value, json)); }
protected override string ToJson(JsonDecimal jsonClass) { return(_convert.ToJson(jsonClass).ToString()); }