public void ReadNodeAttributeSetArray() { var na1 = new NodeAttributeSet(); na1.SetAttribute(Attributes.NodeClass, NodeClass.Variable); na1.SetAttribute(Attributes.BrowseName, new QualifiedName("Somename1")); na1.SetAttribute(Attributes.NodeId, new NodeId(Guid.NewGuid())); na1.SetAttribute(Attributes.DisplayName, new LocalizedText("hello world2")); na1.SetAttribute(Attributes.Value, 623465); na1.SetAttribute(Attributes.Description, new LocalizedText("test22")); na1.SetAttribute(Attributes.DataType, new NodeId(Guid.NewGuid())); var na2 = new NodeAttributeSet(); na2.SetAttribute(Attributes.NodeClass, NodeClass.Variable); na2.SetAttribute(Attributes.BrowseName, new QualifiedName("Somename3")); na2.SetAttribute(Attributes.NodeId, new NodeId(Guid.NewGuid())); na2.SetAttribute(Attributes.DisplayName, new LocalizedText("hello world2")); na2.SetAttribute(Attributes.Value, 345); na2.SetAttribute(Attributes.Description, new LocalizedText("test33")); na2.SetAttribute(Attributes.DataType, new NodeId(Guid.NewGuid())); var na3 = new NodeAttributeSet(); na3.SetAttribute(Attributes.NodeClass, NodeClass.Variable); na3.SetAttribute(Attributes.BrowseName, new QualifiedName("Somename6")); na3.SetAttribute(Attributes.NodeId, new NodeId(Guid.NewGuid())); na3.SetAttribute(Attributes.DisplayName, new LocalizedText("hello world3")); na3.SetAttribute(Attributes.Value, "nanananahhh"); na3.SetAttribute(Attributes.Description, new LocalizedText("test44")); na3.SetAttribute(Attributes.DataType, new NodeId(Guid.NewGuid())); var expected = new[] { na1, na2, na3 }; var json = Serializer.SerializeObject(expected); var result = Serializer.DeserializeObject <NodeAttributeSet[]>(json); Assert.True(expected.SetEqualsSafe(result, Utils.IsEqual)); }
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)); }