public void DataFunctionCall_SetDataDaysTo_Date()
        {
            // Get the search builder.
            var mfSearchBuilder = this.GetSearchBuilder();

            // Create the data function call.
            var dataFunctionCall = new DataFunctionCall();

            dataFunctionCall.SetDataDaysTo();

            // Add a search condition for the SetDataDaysTo data function call.
            mfSearchBuilder.Property
            (
                PropertyValueSearchConditionTestBase.TestDatePropertyId,
                5,
                dataFunctionCall: dataFunctionCall
            );

            // Retrieve the search condition.
            var condition = mfSearchBuilder.Conditions[1];

            // Ensure that the data type is correct.
            Assert.AreEqual
            (
                MFDataType.MFDatatypeInteger,
                condition.TypedValue.DataType
            );

            // Ensure that the search condition has the correct data function call setting.
            Assert.AreEqual
            (
                MFDataFunction.MFDataFunctionDaysTo,
                condition.Expression.DataPropertyValueDataFunction
            );
        }
        /// <summary>
        /// Adds a <see cref="SearchCondition"/> to the collection for a <see cref="MFDataType.MFDatatypeDate"/>
        /// or <see cref="MFDataType.MFDatatypeTimestamp"/> property definition.
        /// This method searches by how many days there are to the property, equivalent to using
        /// a <see cref="DataFunctionCall" /> set to <see cref="DataFunctionCall.SetDataDaysTo"/>.
        /// </summary>
        /// <param name="searchBuilder">The <see cref="MFSearchBuilder"/> to add the condition to.</param>
        /// <param name="propertyDef">The ID of the property to search by.</param>
        /// <param name="value">The number of days to search by.</param>
        /// <param name="conditionType">What type of search to execute (defaults to <see cref="MFConditionType.MFConditionTypeEqual"/>).</param>
        /// <param name="parentChildBehavior">Whether to accept matches to parent/child values as well (defaults to <see cref="MFParentChildBehavior.MFParentChildBehaviorNone"/>).</param>
        /// <param name="indirectionLevels">The indirection levels (from the search object) to access the property to match.</param>
        /// <returns>The <paramref name="searchBuilder"/> provided, for chaining.</returns>
        public static MFSearchBuilder DaysTo
        (
            this MFSearchBuilder searchBuilder,
            int propertyDef,
            int value,
            MFConditionType conditionType              = MFConditionType.MFConditionTypeEqual,
            MFParentChildBehavior parentChildBehavior  = MFParentChildBehavior.MFParentChildBehaviorNone,
            PropertyDefOrObjectTypes indirectionLevels = null
        )
        {
            // Sanity.
            if (null == searchBuilder)
            {
                throw new ArgumentNullException(nameof(searchBuilder));
            }
            if (0 > propertyDef)
            {
                throw new ArgumentOutOfRangeException(nameof(propertyDef), "Property Ids must be greater than -1; ensure that your property alias was resolved.");
            }

            // What is the type of this property?
            var dataType = searchBuilder.Vault.PropertyDefOperations.GetPropertyDef(propertyDef).DataType;

            // What is the data type of the property?
            DataFunctionCall dataFunctionCall;

            switch (dataType)
            {
            case MFDataType.MFDatatypeTimestamp:
            case MFDataType.MFDatatypeDate:

                // Timestamps and dates should be converted to integer using a data function call.
                dataFunctionCall = new DataFunctionCall();
                dataFunctionCall.SetDataDaysTo();

                break;

            default:
                throw new ArgumentException($"Property {propertyDef} is not a date or timestamp property.", nameof(propertyDef));
            }

            // Use the property method.
            return(searchBuilder.Property
                   (
                       propertyDef,
                       value,
                       conditionType,
                       parentChildBehavior,
                       indirectionLevels,
                       dataFunctionCall
                   ));
        }
        public void DataFunctionCall_SetDataDaysTo_InvalidValues(int?value)
        {
            // Get the search builder.
            var mfSearchBuilder = this.GetSearchBuilder();

            // Create the data function call.
            var dataFunctionCall = new DataFunctionCall();

            dataFunctionCall.SetDataDaysTo();

            // Add a search condition for the SetDataDaysTo data function call.
            mfSearchBuilder.Property
            (
                PropertyValueSearchConditionTestBase.TestTimestampPropertyId,
                value,
                dataFunctionCall: dataFunctionCall
            );
        }