public void ShouldReturnObjectMembers() {
      var obj = new JsonObject();
      var member = new JsonObject.JsonMember("name", "value");
      obj.Add(member);
      obj.Add(member);

      var members = obj.Value;
      Assert.That(members.Length, Is.EqualTo(2));
      Assert.That(members[0], Is.EqualTo(member));
    }
    public void ShouldCountTheNumberOfMembers() {
      var obj = new JsonObject();
      Assert.That(obj.Count, Is.EqualTo(0));

      obj = new JsonObject(10);
      Assert.That(obj.Count, Is.EqualTo(0));

      var member = new JsonObject.JsonMember("name", new JsonString("value"));
      obj = new JsonObject(new[] {member});
      Assert.That(obj.Count, Is.EqualTo(1));

      obj.Add(member);
      Assert.That(obj.Count, Is.EqualTo(2));
    }
    public void ShouldSerializeAsJsonObject() {
      var obj = new JsonObject();
      var member = new JsonObject.JsonMember("name", new JsonString("value"));

      Assert.That(obj.AsJson(), Is.EqualTo("{}"));

      obj.Add(member);
      Assert.That(obj.AsJson(),
        Is.EqualTo("{\"name\":\"value\"}"));

      obj.Add(member);
      Assert.That(obj.AsJson(),
        Is.EqualTo("{\"name\":\"value\",\"name\":\"value\"}"));
    }
 /// <summary>
 /// Creates a <see cref="JsonObject"/> containing the data readed from
 /// <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">
 /// A <see cref="IDataReader"/> object that contains the data that will be
 /// used to populate a <see cref="JsonObject"/>.
 /// </param>
 /// <returns>
 /// A <see cref="JsonObject"/> object that contains the data readed from
 /// the <paramref name="reader"/>.
 /// </returns>
 /// <remarks>
 /// This method reads only the first line of th <paramref name="reader"/>
 /// and discards the rest.
 /// </remarks>
 public JsonObject CreateJsonObject(IDataReader reader) {
   JsonObject json_object = new JsonObject();
   if (reader.Read()) {
     IJsonDataField[] json_data_fields = GetJsonDataFields(reader);
     int length = json_data_fields.Length;
     do {
       for (int i = 0, j = length; i < j; i++) {
         IJsonDataField json_data_field = json_data_fields[i];
         JsonObject.JsonMember json_object_member =
           new JsonObject.JsonMember(json_data_field.Name,
             json_data_field.GetValue(reader));
         json_object.Add(json_object_member);
       }
     } while (reader.Read());
   }
   return json_object;
 }