예제 #1
0
        public void should_add_value_array_elements_with_explicit_values()
        {
            var element = new JElement(ElementType.Array);
            element.AddArrayValueElement(true);
            element.AddArrayValueElement(5);
            element.AddArrayValueElement("hai");
            element.AddArrayValueElement(null);

            element.Count().ShouldEqual(4);
            var elements = element.ToList();
            elements[0].ShouldBeAJsonBoolValueArrayElement(true);
            elements[1].ShouldBeAJsonNumberValueArrayElement(5);
            elements[2].ShouldBeAJsonStringValueArrayElement("hai");
            elements[3].ShouldBeAJsonNullValueArrayElement();
        }
예제 #2
0
 public void should_set_multiple_array_elements()
 {
     var element = new JElement(ElementType.Array);
     element.AddArrayValueElement("oh");
     element.AddArrayValueElement("hai");
     _encoder.Encode(element).ShouldEqual("[\"oh\",\"hai\"]");
 }
예제 #3
0
 public void should_set_escaped_array_string_elements()
 {
     var element = new JElement(ElementType.Array);
     element.Type = ElementType.Array;
     element.AddArrayValueElement(DateTime.MaxValue.ToString());
     _encoder.Encode(element).ShouldEqual("[\"{0}\"]"
         .ToFormat(DateTime.MaxValue.ToString().Replace("/", "\\/")));
 }
예제 #4
0
 public void should_set_array_string_elements()
 {
     var element = new JElement(ElementType.Array);
     element.Type = ElementType.Array;
     element.AddArrayValueElement("hai");
     element.AddArrayValueElement('y');
     _encoder.Encode(element).ShouldEqual("[\"hai\",\"y\"]");
 }
예제 #5
0
 public void should_set_array_number_elements()
 {
     var element = new JElement(ElementType.Array);
     element.Type = ElementType.Array;
     element.AddArrayValueElement((decimal)1.1);
     element.AddArrayValueElement((float)2.2);
     element.AddArrayValueElement((double)3.3);
     element.AddArrayValueElement((sbyte)4);
     element.AddArrayValueElement((byte)5);
     element.AddArrayValueElement((short)6);
     element.AddArrayValueElement((ushort)7);
     element.AddArrayValueElement((int)8);
     element.AddArrayValueElement((uint)9);
     element.AddArrayValueElement((long)10);
     element.AddArrayValueElement((ulong)11);
     _encoder.Encode(element).ShouldEqual("[1.1,2.2,3.3,4,5,6,7,8,9,10,11]");
 }
예제 #6
0
 public void should_set_array_null_element()
 {
     var element = new JElement(ElementType.Array);
     element.AddArrayValueElement(null);
     _encoder.Encode(element).ShouldEqual("[null]");
 }
예제 #7
0
 public void should_set_array_bool_element()
 {
     var element = new JElement(ElementType.Array);
     element.AddArrayValueElement(true);
     _encoder.Encode(element).ShouldEqual("[true]");
 }