예제 #1
0
        public void ReadNodeAttributeSet(string encoderType, string decoderType)
        {
            var expected = new NodeAttributeSet();
            var map      = new AttributeMap();

            expected.SetAttribute(Attributes.NodeClass, NodeClass.Variable);
            expected.SetAttribute(Attributes.BrowseName, new QualifiedName("Somename"));
            expected.SetAttribute(Attributes.NodeId, new NodeId(Guid.NewGuid()));
            expected.SetAttribute(Attributes.DisplayName, new LocalizedText("en-us", "hello world"));
            expected.SetAttribute(Attributes.Value, 1235);
            expected.SetAttribute(Attributes.Description, new LocalizedText("test"));
            expected.SetAttribute(Attributes.DataType, new NodeId(Guid.NewGuid()));
            CreateSerializers(out var encoder, out var decoder);

            var buffer = encoder.Encode(encoderType, e => e.WriteEncodeable("test", expected, expected.GetType()));

            OutputJsonBuffer(encoderType, buffer);
            var result = decoder.Decode(decoderType, buffer, d => d.ReadEncodeable("test", typeof(NodeAttributeSet)));

            // The NR encoding ignores the Locale, skip the validation
            if (!IsNonReversibleEncoding(encoderType))
            {
                Assert.True(expected.IsEqual(result));
            }
        }
        public void ReadNodeAttributeSet()
        {
            var expected = new NodeAttributeSet();

            expected.SetAttribute(Attributes.NodeClass, NodeClass.Variable);
            expected.SetAttribute(Attributes.BrowseName, new QualifiedName("Somename"));
            expected.SetAttribute(Attributes.NodeId, new NodeId(Guid.NewGuid()));
            expected.SetAttribute(Attributes.DisplayName, new LocalizedText("hello world"));
            expected.SetAttribute(Attributes.Value, 1235);
            expected.SetAttribute(Attributes.Description, new LocalizedText("test"));
            expected.SetAttribute(Attributes.DataType, new NodeId(Guid.NewGuid()));
            var json   = Serializer.SerializeObject(expected);
            var result = Serializer.DeserializeObject <NodeAttributeSet>(json);

            Assert.True(expected.IsEqual(result));
        }