/// <summary>
    /// Gets the text value of an object.
    /// </summary>
    /// <param name="value">The value.</param>
    /// <returns>A formatted text representation of the value.</returns>
    /// <remarks>DateValue is formatted in yyyy-mm-dd format. DateTimeValue is
    /// formatted in yyyy-mm-dd HH:mm:ss Z format.</remarks>
    private static string getTextValue(Object value) {
      if (value == null) {
        return "";
      }

      if (value is DateValue) {
        Google.Api.Ads.Dfp.v201408.DateValue dateValue =
            (Google.Api.Ads.Dfp.v201408.DateValue) value;
        return string.Format("{0:0000}-{1:00}-{2:00}", dateValue.value.year, dateValue.value.month,
            dateValue.value.day);
      } else if (value is DateTimeValue) {
        Google.Api.Ads.Dfp.v201408.DateTimeValue dateTimeValue =
            (Google.Api.Ads.Dfp.v201408.DateTimeValue) value;
        return string.Format("{0:0000}-{1:00}-{2:00}T{3:00}:{4:00}:{5:00} {6}",
            dateTimeValue.value.date.year, dateTimeValue.value.date.month,
            dateTimeValue.value.date.day, dateTimeValue.value.hour,
            dateTimeValue.value.minute, dateTimeValue.value.second,
            dateTimeValue.value.timeZoneID);
      } else if (value is List<object>) {
        List<string> textValues = (value as List<object>)
            .ConvertAll(new Converter<object, string>(getTextValue))
            .ConvertAll(new Converter<string, string>(EscapeCsv));
        return String.Join<string>(",", textValues);
      } else {
        // NumberValue, BooleanValue, TextValue
        return value.ToString();
      }
    }
 public void TestGetObjectDateValue() {
   Date date = new Date();
   date.year = 2012;
   date.month = 12;
   date.day = 2;
   DateValue dateValue = new DateValue();
   dateValue.value = date;
   Assert.AreEqual(date, PqlUtilities.GetValue(dateValue));
 }
        public void TestGetObjectDateSetValue()
        {
            DateTime dateTime = new DateTime();
              Date date = new Date();
              date.year = 2012;
              date.month = 12;
              date.day = 2;
              DateValue dateValue = new DateValue();
              dateValue.value = date;

              SetValue setValue = new SetValue();
              setValue.values = new Value[] { dateValue };
              List<object> value = PqlUtilities.GetValue(setValue) as List<object>;
              Assert.AreEqual(1, value.Count);
              Assert.True(value.Contains(date));
        }
    public void TestGetObjectMixedSetValue() {
      TextValue textValue = new TextValue();
      DateValue dateValue = new DateValue();
      textValue.value = "value1";
      Date date = new Date();
      date.year = 2012;
      date.month = 12;
      date.day = 2;
      dateValue.value = date;

      SetValue setValue = new SetValue();
      setValue.values = new Value[] { textValue, dateValue };
      PqlUtilities.GetValue(setValue);
    }
 /// <summary>
 /// Adds a new Date value to the list of query parameters.
 /// </summary>
 /// <param name="key">The parameter name.</param>
 /// <param name="value">The parameter value.</param>
 /// <returns>The statement builder, for chaining method calls.</returns>
 public StatementBuilder AddValue(string key, Date value)
 {
     DateValue queryValue = new DateValue();
       queryValue.value = value;
       return AddValue(key, queryValue);
 }