public void FromJson_CorrectJsonClass() { //arrange var json = ExpectedJson; var jsonClass = new JsonFloatClass(); //act _convert.FromJson(jsonClass, json); //assert Assert.That(jsonClass.Age, Is.EqualTo(42.21f)); Assert.That(jsonClass.Height, Is.EqualTo(176.568f)); Assert.That(jsonClass.Min, Is.EqualTo(float.MinValue)); Assert.That(jsonClass.Max, Is.EqualTo(float.MaxValue)); Assert.That(jsonClass.Zero, Is.EqualTo(0)); }
public void ToJson_CorrectString() { //arrange var jsonClass = new JsonFloatClass() { Age = 42.21f, Height = 176.568f, Max = float.MaxValue, Min = float.MinValue, Zero = 0 }; //act var json = _convert.ToJson(jsonClass); //assert Assert.That(json, Is.EqualTo(ExpectedJson)); }
public void ToJson_CorrectString() { //arrange var jsonClass = new JsonFloatClass() { Age = 42.21f, Height = 176.568f, Max = float.MaxValue, Min = float.MinValue, Zero = 0 }; //act var json = ToJson(jsonClass); //assert var resultClass = System.Text.Json.JsonSerializer.Deserialize <JsonFloatClass>(json); Assert.That(resultClass.Age, Is.EqualTo(jsonClass.Age)); Assert.That(resultClass.Height, Is.EqualTo(jsonClass.Height)); Assert.That(resultClass.Max, Is.EqualTo(jsonClass.Max)); Assert.That(resultClass.Min, Is.EqualTo(jsonClass.Min)); Assert.That(resultClass.Zero, Is.EqualTo(jsonClass.Zero)); }
protected abstract ReadOnlySpan <char> FromJson(JsonFloatClass value, string json);
protected abstract string ToJson(JsonFloatClass jsonClass);
protected override ReadOnlySpan <char> FromJson(JsonFloatClass value, string json) { return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json)))); }
protected override string ToJson(JsonFloatClass jsonClass) { var jsonUtf8 = _convert.ToJsonUtf8(jsonClass); return(Encoding.UTF8.GetString(jsonUtf8)); }
protected override ReadOnlySpan <char> FromJson(JsonFloatClass value, string json) { return(_convert.FromJson(value, json)); }
protected override string ToJson(JsonFloatClass jsonClass) { return(_convert.ToJson(jsonClass).ToString()); }