Exemplo n.º 1
0
        public void ToJson_CorrectString()
        {
            //arrange
            var jsonClass = new JsonArrayClass()
            {
                BooleanArray = new bool[] { true, false }
            };

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

            //assert
            Assert.That(json, Is.EqualTo(ExpectedJson));
        }
Exemplo n.º 2
0
        public void ToJson_Null_CorrectString()
        {
            //arrange
            var jsonClass = new JsonArrayClass()
            {
                BooleanArray = null
            };

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

            //assert
            Assert.That(json, Is.EqualTo("{\"BooleanArray\":null}"));
        }
Exemplo n.º 3
0
        public void FromJson_PopulatedArray_CorrectArray()
        {
            //arrange
            var jsonClass = new JsonArrayClass()
            {
                BooleanArray = new bool[] { false, false, false }
            };

            //act
            _convert.FromJson(jsonClass, ExpectedJson);

            //assert
            Assert.That(jsonClass.BooleanArray.Length, Is.EqualTo(2));
            Assert.That(jsonClass.BooleanArray[0], Is.True);
            Assert.That(jsonClass.BooleanArray[1], Is.False);
        }
Exemplo n.º 4
0
        public void FromJson_EmptyArray_CorrectArray()
        {
            //arrange
            var jsonClass = new JsonArrayClass()
            {
                BooleanArray = new bool[0]
            };

            //act
            FromJson(jsonClass, ExpectedJson);

            //assert
            Assert.That(jsonClass.BooleanArray.Length, Is.EqualTo(2));
            Assert.That(jsonClass.BooleanArray[0], Is.True);
            Assert.That(jsonClass.BooleanArray[1], Is.False);
        }
Exemplo n.º 5
0
 protected abstract ReadOnlySpan <char> FromJson(JsonArrayClass value, string json);
Exemplo n.º 6
0
 protected abstract string ToJson(JsonArrayClass jsonClass);
Exemplo n.º 7
0
 protected override ReadOnlySpan <char> FromJson(JsonArrayClass value, string json)
 {
     return(Encoding.UTF8.GetString(_convert.FromJson(value, Encoding.UTF8.GetBytes(json))));
 }
Exemplo n.º 8
0
        protected override string ToJson(JsonArrayClass jsonClass)
        {
            var jsonUtf8 = _convert.ToJsonUtf8(jsonClass);

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