public void ToJson_Null_CorrectString() { //arrange var jsonClass = new JsonListClass() { BooleanList = null }; //act var json = _convert.ToJson(jsonClass); //assert Assert.That(json.ToString(), Is.EqualTo("{\"BooleanList\":null}")); }
public void FromJson_NullList_CorrectList() { //arrange var jsonClass = new JsonListClass() { BooleanList = null }; //act _convert.FromJson(jsonClass, ExpectedJson); //assert Assert.That(jsonClass.BooleanList.Count, Is.EqualTo(2)); Assert.That(jsonClass.BooleanList[0], Is.True); Assert.That(jsonClass.BooleanList[1], Is.False); }
public void ToJson_CorrectString() { //arrange var jsonClass = new JsonListClass() { BooleanList = new List <bool>() { true, false } }; //act var json = _convert.ToJson(jsonClass); //assert Assert.That(json.ToString(), Is.EqualTo(ExpectedJson)); }
public void FromJson_PopulatedList_CorrectList() { //arrange var jsonClass = new JsonListClass() { BooleanList = new List <bool>() { false, false, false } }; //act FromJson(jsonClass, ExpectedJson); //assert Assert.That(jsonClass.BooleanList.Count, Is.EqualTo(2)); Assert.That(jsonClass.BooleanList[0], Is.True); Assert.That(jsonClass.BooleanList[1], Is.False); }
protected abstract ReadOnlySpan <char> FromJson(JsonListClass value, string json);
protected abstract string ToJson(JsonListClass jsonClass);
protected override ReadOnlySpan <char> FromJson(JsonListClass value, string json) { return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json)))); }
protected override string ToJson(JsonListClass jsonClass) { var jsonUtf8 = _convert.ToJsonUtf8(jsonClass); return(Encoding.UTF8.GetString(jsonUtf8)); }
protected override ReadOnlySpan <char> FromJson(JsonListClass value, string json) { return(_convert.FromJson(value, json)); }
protected override string ToJson(JsonListClass jsonClass) { return(_convert.ToJson(jsonClass).ToString()); }