Beispiel #1
0
        public void DataFunctionCall_SetDataMonth()
        {
            // Get the search builder.
            var mfSearchBuilder = this.GetSearchBuilder();

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

            dataFunctionCall.SetDataMonth();

            // Add a search condition for the SetDataMonth data function call.
            mfSearchBuilder.Property
            (
                PropertyValueSearchConditionTestBase.TestTimestampPropertyId,
                "02",
                dataFunctionCall: dataFunctionCall
            );

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

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

            // Ensure that the search condition has the correct data function call setting.
            Assert.AreEqual
            (
                MFDataFunction.MFDataFunctionMonth,
                condition.Expression.DataPropertyValueDataFunction
            );
        }
Beispiel #2
0
        /// <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 solely by the month component in the property value , equivalent to using
        /// a <see cref="DataFunctionCall" /> set to <see cref="DataFunctionCall.SetDataMonth" />.
        /// </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="month">The 1-based number of the month to search by (1 = January, 12 = December).</param>
        /// <param name="conditionType">What type of search to execute (defaults to <see cref="MFConditionType.MFConditionTypeEqual"/>).</param>
        /// <param name="indirectionLevels">The indirection levels (from the search object) to access the property to match.</param>
        /// <param name="parentChildBehavior">Whether to accept matches to parent/child values as well (defaults to <see cref="MFParentChildBehavior.MFParentChildBehaviorNone"/>).</param>
        /// <returns>The <paramref name="searchBuilder"/> provided, for chaining.</returns>
        public static MFSearchBuilder Month
        (
            this MFSearchBuilder searchBuilder,
            int propertyDef,
            int month,
            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.");
            }
            if (month < 1 || month > 12)
            {
                throw new ArgumentOutOfRangeException(nameof(month), "The month number must be between 1 and 12 inclusive.");
            }

            // 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 text using a data function call.
                dataFunctionCall = new DataFunctionCall();
                dataFunctionCall.SetDataMonth();

                break;

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

            // Use the property method.
            return(searchBuilder.Property
                   (
                       propertyDef,
                       month.ToString("00"),
                       conditionType,
                       parentChildBehavior,
                       indirectionLevels,
                       dataFunctionCall
                   ));
        }
Beispiel #3
0
        public void DataFunctionCall_SetDataMonth_InvalidValues(string value)
        {
            // Get the search builder.
            var mfSearchBuilder = this.GetSearchBuilder();

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

            dataFunctionCall.SetDataMonth();

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