コード例 #1
0
        public void ChangedItemDetected()
        {
            var oldCollection = new MFilesAPI.PropertyValues();
            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
                oldCollection.Add(-1, p);
            }
            var newCollection = new MFilesAPI.PropertyValues();
            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello new world");
                newCollection.Add(-1, p);
            }

            var changes = newCollection.GetChanges(oldCollection, out bool changed);

            Assert.IsTrue(changed);
            Assert.AreEqual(1, changes.Count());
            Assert.AreEqual(PropertyValueChangeType.Modified, changes.ElementAt(0).ChangeType);
            Assert.AreEqual(123, changes.ElementAt(0).PropertyDef);
        }
コード例 #2
0
        public void IncludeItemsThatHaveNotChanged_True()
        {
            var oldCollection = new MFilesAPI.PropertyValues();
            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
                oldCollection.Add(-1, p);
            }
            var newCollection = new MFilesAPI.PropertyValues();
            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
                newCollection.Add(-1, p);
            }

            var returned = newCollection.GetChanges(oldCollection, out bool changed, includePropertiesThatHaveNotChanged: true);

            Assert.IsFalse(changed);             // The collection has not changed, even though items are returned.
            Assert.AreEqual(1, returned.Count());
            Assert.AreEqual(PropertyValueChangeType.None, returned.ElementAt(0).ChangeType);
            Assert.AreEqual(123, returned.ElementAt(0).PropertyDef);
        }
コード例 #3
0
        public void IncludeItemsThatHaveNotChanged_False()
        {
            var oldCollection = new MFilesAPI.PropertyValues();
            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
                oldCollection.Add(-1, p);
            }
            var newCollection = new MFilesAPI.PropertyValues();
            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
                newCollection.Add(-1, p);
            }

            var changes = newCollection.GetChanges(oldCollection, out bool changed, includePropertiesThatHaveNotChanged: false);

            Assert.IsFalse(changed);
            Assert.AreEqual(0, changes.Count());
        }
コード例 #4
0
        public void ReturnsTrueIfExists()
        {
            var propertyValues = new MFilesAPI.PropertyValues();

            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
                propertyValues.Add(-1, p);
            }

            Assert.IsTrue(propertyValues.Exists(123));
        }
コード例 #5
0
        public void ReturnsValueIfExists()
        {
            var propertyValues = new MFilesAPI.PropertyValues();
            {
                var p = new MFilesAPI.PropertyValue()
                {
                    PropertyDef = 123
                };
                p.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
                propertyValues.Add(-1, p);
            }

            var value = propertyValues.GetProperty(123);

            Assert.IsNotNull(value);
            Assert.AreEqual(123, value.PropertyDef);
            Assert.AreEqual(MFDataType.MFDatatypeText, value.Value.DataType);
            Assert.AreEqual("hello world", value.Value.Value);
        }
コード例 #6
0
        public void DoesNotThrowWithNullOldVersion()
        {
            var changes = new MFilesAPI.PropertyValues().GetChanges(null).ToList();

            Assert.IsNotNull(changes);
        }