コード例 #1
0
        public void AddValueToProperty_Adds()
        {
            // Set up the instruction to add/update.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.AddValueToProperty,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
                }
            };

            instruction.PropertyValue.TypedValue.SetValue
            (
                MFDataType.MFDatatypeLookup,
                (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument
            );

            // Apply it.
            var propertyValues = new PropertyValues();

            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(1, propertyValues.Count);
            Assert.AreEqual((int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass, propertyValues[1].PropertyDef);
            Assert.AreEqual
            (
                (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument,
                propertyValues[1].TypedValue.GetLookupID()
            );
        }
コード例 #2
0
        public void RemoveProperty()
        {
            // Set up the instruction to remove.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.RemovePropertyValue,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
                }
            };

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
                };
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(0, propertyValues.Count);
        }
コード例 #3
0
        public void AddValueToProperty_AddsMultipleValues_Null()
        {
            const int propertyDef = 1024;

            // Set up the instruction to add/update.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.AddValueToProperty,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = propertyDef
                }
            };

            instruction.PropertyValue.TypedValue.SetValue
            (
                MFDataType.MFDatatypeMultiSelectLookup,
                new int[] { 4, 5, 6 }
            );

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = propertyDef
                };
                // Set the starting value to null (should end up with one item).
                pv.TypedValue.SetValueToNULL(MFDataType.MFDatatypeMultiSelectLookup);
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(1, propertyValues.Count);
            Assert.AreEqual(propertyDef, propertyValues[1].PropertyDef);
            Assert.AreEqual
            (
                3,
                propertyValues[1].TypedValue.GetValueAsLookups().Count
            );

            // Check they are as expected.
            Assert.AreEqual
            (
                4,
                propertyValues[1].TypedValue.GetValueAsLookups()[1].Item
            );
            Assert.AreEqual
            (
                5,
                propertyValues[1].TypedValue.GetValueAsLookups()[2].Item
            );
            Assert.AreEqual
            (
                6,
                propertyValues[1].TypedValue.GetValueAsLookups()[3].Item
            );
        }
コード例 #4
0
        public void AddValueToProperty_AddsSingleValue_SingleNewValue_NoOverlap()
        {
            const int propertyDef = 1024;

            // Set up the instruction to add/update.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.AddValueToProperty,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = propertyDef
                }
            };

            instruction.PropertyValue.TypedValue.SetValue
            (
                MFDataType.MFDatatypeMultiSelectLookup,
                new int[] { 6 }
            );

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = propertyDef
                };
                // Set the starting value to a single item (should end up with two).
                pv.TypedValue.SetValue(MFDataType.MFDatatypeMultiSelectLookup, new int[] { 4 });
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(1, propertyValues.Count);
            Assert.AreEqual(propertyDef, propertyValues[1].PropertyDef);
            Assert.AreEqual
            (
                2,
                propertyValues[1].TypedValue.GetValueAsLookups().Count
            );
            Assert.AreEqual
            (
                4,                 // This is the starting one.
                propertyValues[1].TypedValue.GetValueAsLookups()[1].Item
            );
            Assert.AreEqual
            (
                6,                 // This is the single ID that was added.
                propertyValues[1].TypedValue.GetValueAsLookups()[2].Item
            );
        }
コード例 #5
0
        public void AddValueToProperty_ThrowsForUnsupportedDataType
        (
            MFDataType dataType,
            object initialValue,
            object newValue
        )
        {
            const int propertyDefId = 12345;

            // Set up the instruction to add/update.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.AddValueToProperty,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = propertyDefId
                }
            };

            instruction.PropertyValue.TypedValue.SetValue
            (
                dataType,
                newValue                 // Add the new value.
            );

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = propertyDefId
                };
                // Set the starting value the initial value.
                pv.TypedValue.SetValue
                (
                    dataType,
                    initialValue
                );
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);
        }
コード例 #6
0
        public void ReplacePropertyValue_Replaces()
        {
            // Set up the instruction to replace.
            var instruction = new ObjectCopyOptions.PropertyValueInstruction()
            {
                InstructionType = ObjectCopyOptions.PropertyValueInstructionType.ReplaceOrAddPropertyValue,
                PropertyValue   = new PropertyValue()
                {
                    PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
                }
            };

            instruction.PropertyValue.TypedValue.SetValue
            (
                MFDataType.MFDatatypeLookup,
                (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassUnclassifiedDocument
            );

            // Apply it.
            var propertyValues = new PropertyValues();

            {
                var pv = new PropertyValue()
                {
                    PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
                };
                // Set the starting value to "other document".  Should be replaced.
                pv.TypedValue.SetValue(MFDataType.MFDatatypeLookup, (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument);
                propertyValues.Add(-1, pv);
            }
            instruction.ApplyTo(propertyValues);

            // Test the results.
            Assert.AreEqual(1, propertyValues.Count);
            Assert.AreEqual((int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass, propertyValues[1].PropertyDef);
            Assert.AreEqual
            (
                (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassUnclassifiedDocument,
                propertyValues[1].TypedValue.GetLookupID()
            );
        }