public void ReturnsCorrectly()
        {
            string attributeValue1 = "AttributeValue1";
            string attributeValue2 = "AttributeValue2";

            var attributeValueCollection = new AttributeValueCollection();
            attributeValueCollection.Add( attributeValue1 );
            attributeValueCollection.Add( attributeValue2 );

            var result = attributeValueCollection.ToString();

            string expectedResult = string.Format( "{0} {1}", attributeValue1, attributeValue2 );
            Assert.AreEqual( expectedResult, result );
        }
Esempio n. 2
0
        internal static AttributeValueCollection GetAttributeValueCollection(OPCHDA_ATTRIBUTE input, bool deallocate)
        {
            AttributeValueCollection values = new AttributeValueCollection {
                AttributeID = input.dwAttributeID
            };

            object[]   objArray  = OpcCom.Interop.GetVARIANTs(ref input.vAttributeValues, input.dwNumValues, deallocate);
            DateTime[] timeArray = OpcCom.Interop.GetFILETIMEs(ref input.ftTimeStamps, input.dwNumValues, deallocate);
            for (int i = 0; i < input.dwNumValues; i++)
            {
                AttributeValue value2 = new AttributeValue {
                    Value     = objArray[i],
                    Timestamp = timeArray[i]
                };
                values.Add(value2);
            }
            return(values);
        }
        /// <summary>
        /// Unmarshals and deallocates an OPCHDA_ATTRIBUTE structure.
        /// </summary>
        internal static AttributeValueCollection GetAttributeValueCollection(OpcRcw.Hda.OPCHDA_ATTRIBUTE input, bool deallocate)
        {
            AttributeValueCollection output = new AttributeValueCollection();

            output.AttributeID = input.dwAttributeID;

            object[]   values     = OpcCom.Interop.GetVARIANTs(ref input.vAttributeValues, input.dwNumValues, deallocate);
            DateTime[] timestamps = OpcCom.Interop.GetFILETIMEs(ref input.ftTimeStamps, input.dwNumValues, deallocate);

            for (int ii = 0; ii < input.dwNumValues; ii++)
            {
                AttributeValue value = new AttributeValue();

                value.Value     = values[ii];
                value.Timestamp = timestamps[ii];

                output.Add(value);
            }

            return(output);
        }