Example #1
0
        public void EtpSupportedDataObjectCollection_Intersection_DataObject_In_Common()
        {
            var instanceDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Well"), new EtpDataObjectCapabilities {
                    ActiveTimeoutPeriod = int.MaxValue
                }),
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Wellbore"), new EtpDataObjectCapabilities {
                    MaxDataObjectSize = 999999999
                }),
            };
            var counterpartDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Well"), new EtpDataObjectCapabilities {
                    SupportsPut = false
                }),
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "ChannelSet"), new EtpDataObjectCapabilities {
                    SupportsDelete = true
                }),
            };

            var collection = EtpSupportedDataObjectCollection.GetSupportedDataObjectCollection(instanceDataObjects, counterpartDataObjects, true);

            Assert.AreEqual(1, collection.SupportedTypes.Count());
            Assert.AreEqual(int.MaxValue, collection.SupportedTypes.First().Capabilities.ActiveTimeoutPeriod);
            Assert.AreEqual(false, collection.SupportedTypes.First().CounterpartCapabilities.SupportsPut);
            Assert.AreEqual(0, collection.SupportedFamilies.Count());
        }
Example #2
0
        public void EtpSupportedDataObjectCollection_Intersection_Instance_DataObjects_And_Counterpart_WildCard()
        {
            var instanceDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Well"), new EtpDataObjectCapabilities {
                    ActiveTimeoutPeriod = int.MaxValue
                }),
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Wellbore"), new EtpDataObjectCapabilities {
                    MaxDataObjectSize = 999999999
                }),
                new EtpSupportedDataObject(new EtpDataObjectType("prodml", "2.0", "*"), new EtpDataObjectCapabilities {
                    SupportsDelete = true
                }),
            };
            var counterpartDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "*"), new EtpDataObjectCapabilities {
                    SupportsPut = false
                }),
            };

            var collection = EtpSupportedDataObjectCollection.GetSupportedDataObjectCollection(instanceDataObjects, counterpartDataObjects, true);

            Assert.AreEqual(2, collection.SupportedTypes.Count());
            Assert.AreEqual("Well", collection.SupportedTypes.ToList()[0].QualifiedType.ObjectType);
            Assert.AreEqual("Wellbore", collection.SupportedTypes.ToList()[1].QualifiedType.ObjectType);
            Assert.AreEqual(int.MaxValue, collection.SupportedTypes.First().Capabilities.ActiveTimeoutPeriod);
            Assert.AreEqual(false, collection.SupportedTypes.First().CounterpartCapabilities.SupportsPut);
            Assert.AreEqual(0, collection.SupportedFamilies.Count());
        }
Example #3
0
        /// <summary>
        /// Returns a new <see cref="EtpSupportedDataObjectCollection"/> that representes the intersection of supported data objects between this instance and the other instance.
        /// </summary>
        /// <param name="instanceSupportedDataObjects">The ETP endpoint's supported data objects.</param>
        /// <param name="counterpartSupportedDataObjects">The ETP endpoint's counterpart's supported data objects.</param>
        /// <param name="intersection">If <c>true</c>, the collection is the intersection of data objects supported by the instance and its counterpart; if <c>false</c> it is the union.</param>
        /// <returns>The new collection representing the intersection of the supported data objects.</returns>
        public static EtpSupportedDataObjectCollection GetSupportedDataObjectCollection(IEnumerable <EtpSupportedDataObject> instanceSupportedDataObjects, IEnumerable <EtpSupportedDataObject> counterpartSupportedDataObjects, bool intersection)
        {
            var instanceCollection    = new EtpSupportedDataObjectCollection(instanceSupportedDataObjects);
            var counterpartCollection = new EtpSupportedDataObjectCollection(counterpartSupportedDataObjects);

            var supportedDataObjects = new List <EtpSupportedDataObject>();

            // First handle wildcards found in both sets
            foreach (var instanceFamily in instanceCollection.SupportedFamilies)
            {
                var counterpartFamily = counterpartCollection.TryGetMatchingDataObject(instanceFamily.QualifiedType);
                if (!intersection || counterpartFamily != null)
                {
                    supportedDataObjects.Add(instanceFamily);
                    instanceFamily.CounterpartCapabilities = counterpartFamily?.Capabilities ?? new EtpDataObjectCapabilities();
                }
            }

            if (!intersection)
            {
                foreach (var counterpartFamily in counterpartCollection.SupportedFamilies)
                {
                    var instanceFamily = instanceCollection.TryGetMatchingDataObject(counterpartFamily.QualifiedType);
                    if (instanceFamily == null)
                    {
                        var supportedDataObject = new EtpSupportedDataObject(counterpartFamily.QualifiedType, null);
                        supportedDataObject.CounterpartCapabilities = counterpartFamily.Capabilities;

                        supportedDataObjects.Add(supportedDataObject);
                    }
                }
            }

            // Next handle explicit types from instance found in counterpart as either an explicit type or a family
            foreach (var instanceType in instanceCollection.SupportedTypes)
            {
                var counterpartDataObject = counterpartCollection.TryGetMatchingDataObject(instanceType.QualifiedType);
                if (!intersection || counterpartDataObject != null)
                {
                    supportedDataObjects.Add(instanceType);
                    instanceType.CounterpartCapabilities = counterpartDataObject?.Capabilities ?? new EtpDataObjectCapabilities();
                }
            }

            // Last handle explicit types from counterpart
            foreach (var counterpartType in counterpartCollection.SupportedTypes)
            {
                var instanceDataObject = instanceCollection.TryGetMatchingDataObject(counterpartType.QualifiedType);
                if ((!intersection && (instanceDataObject == null || instanceDataObject.QualifiedType.IsWildcard)) || (intersection && instanceDataObject != null && instanceDataObject.QualifiedType.IsWildcard))
                {
                    var supportedDataObject = new EtpSupportedDataObject(counterpartType.QualifiedType, instanceDataObject?.Capabilities);
                    supportedDataObject.CounterpartCapabilities = counterpartType.Capabilities;

                    supportedDataObjects.Add(supportedDataObject);
                }
            }

            return(new EtpSupportedDataObjectCollection(supportedDataObjects));
        }
Example #4
0
        public void EtpSupportedDataObjectCollection_Union_Nothing_In_Common()
        {
            var instanceDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "*")),
            };
            var counterpartDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("resqml", "2.0.1", "*")),
            };

            var collection = EtpSupportedDataObjectCollection.GetSupportedDataObjectCollection(instanceDataObjects, counterpartDataObjects, false);

            Assert.AreEqual(0, collection.SupportedTypes.Count());
            Assert.AreEqual(2, collection.SupportedFamilies.Count());
        }
Example #5
0
        public void EtpSupportedDataObjectCollection_Union_DataObject_In_Common()
        {
            var instanceDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Well")),
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Wellbore")),
            };
            var counterpartDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Well")),
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "ChannelSet")),
            };

            var collection = EtpSupportedDataObjectCollection.GetSupportedDataObjectCollection(instanceDataObjects, counterpartDataObjects, false);

            Assert.AreEqual(3, collection.SupportedTypes.Count());
            Assert.AreEqual(0, collection.SupportedFamilies.Count());
        }
Example #6
0
        public void EtpSupportedDataObjectCollection_Union_Instance_DataObjects_And_Counterpart_Empty()
        {
            var instanceDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Well")),
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Wellbore")),
                new EtpSupportedDataObject(new EtpDataObjectType("prodml", "2.0", "*")),
            };
            var counterpartDataObjects = new List <EtpSupportedDataObject>
            {
            };

            var collection = EtpSupportedDataObjectCollection.GetSupportedDataObjectCollection(instanceDataObjects, counterpartDataObjects, false);

            Assert.AreEqual(2, collection.SupportedTypes.Count());
            Assert.AreEqual("Well", collection.SupportedTypes.ToList()[0].QualifiedType.ObjectType);
            Assert.AreEqual("Wellbore", collection.SupportedTypes.ToList()[1].QualifiedType.ObjectType);
            Assert.AreEqual(1, collection.SupportedFamilies.Count());
        }
Example #7
0
        public void EtpSupportedDataObjectCollection_Intersection_Nothing_In_Common()
        {
            var instanceDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "*"), new EtpDataObjectCapabilities {
                    ActiveTimeoutPeriod = int.MaxValue
                }),
            };
            var counterpartDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("resqml", "2.0.1", "*"), new EtpDataObjectCapabilities {
                    MaxDataObjectSize = 999999999
                }),
            };

            var collection = EtpSupportedDataObjectCollection.GetSupportedDataObjectCollection(instanceDataObjects, counterpartDataObjects, true);

            Assert.AreEqual(0, collection.SupportedTypes.Count());
            Assert.AreEqual(0, collection.SupportedFamilies.Count());
        }
Example #8
0
        public void EtpSupportedDataObjectCollection_Intersection_Instance_DataObjects_And_Counterpart_Empty()
        {
            var instanceDataObjects = new List <EtpSupportedDataObject>
            {
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Well"), new EtpDataObjectCapabilities {
                    ActiveTimeoutPeriod = int.MaxValue
                }),
                new EtpSupportedDataObject(new EtpDataObjectType("witsml", "2.0", "Wellbore"), new EtpDataObjectCapabilities {
                    MaxDataObjectSize = 999999999
                }),
                new EtpSupportedDataObject(new EtpDataObjectType("prodml", "2.0", "*"), new EtpDataObjectCapabilities {
                    SupportsDelete = true
                }),
            };
            var counterpartDataObjects = new List <EtpSupportedDataObject>
            {
            };

            var collection = EtpSupportedDataObjectCollection.GetSupportedDataObjectCollection(instanceDataObjects, counterpartDataObjects, true);

            Assert.AreEqual(0, collection.SupportedTypes.Count());
            Assert.AreEqual(0, collection.SupportedFamilies.Count());
        }