Exemplo n.º 1
0
        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}"));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 protected abstract ReadOnlySpan <char> FromJson(JsonListClass value, string json);
Exemplo n.º 6
0
 protected abstract string ToJson(JsonListClass jsonClass);
Exemplo n.º 7
0
 protected override ReadOnlySpan <char> FromJson(JsonListClass value, string json)
 {
     return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json))));
 }
Exemplo n.º 8
0
        protected override string ToJson(JsonListClass jsonClass)
        {
            var jsonUtf8 = _convert.ToJsonUtf8(jsonClass);

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