public void EncodeDecodeNodeIdWithNullStringAndDefaultUri() { var context = new ServiceMessageContext(); var input = new NodeId((string)null, 0); // == NodeId.Null var s1 = input.AsString(context); var s2 = input.AsString(context, true); var result1 = s1.ToNodeId(context); var result2 = s2.ToNodeId(context); AssertEqual(NodeId.Null, result1, result2); }
public void EncodeDecodeNodeIdWithBufferAndDefaultUri() { var context = new ServiceMessageContext(); var expected = new NodeId(Guid.NewGuid().ToByteArray(), 0); var s1 = expected.AsString(context); var s2 = expected.AsString(context, true); var result1 = s1.ToNodeId(context); var result2 = s2.ToNodeId(context); AssertEqual(expected, result1, result2); }
public void EncodeDecodeNodeIdWithIntAndDefaultUri() { var context = new ServiceMessageContext(); var expected = new NodeId(111111111, 0); var s1 = expected.AsString(context); var s2 = expected.AsString(context, true); var result1 = s1.ToNodeId(context); var result2 = s2.ToNodeId(context); AssertEqual(expected, result1, result2); }
public void EncodeDecodeNodeIdWithStringAndDefaultUri() { var context = new ServiceMessageContext(); var expected = new NodeId(" space tests /(%)§;#;;#;()§$\"))\"\")(§", 0); var s1 = expected.AsString(context); var s2 = expected.AsString(context, true); var result1 = s1.ToNodeId(context); var result2 = s2.ToNodeId(context); AssertEqual(expected, result1, result2); }
public void EncodeDecodeNodeIdWithEmptyString() { var context = new ServiceMessageContext(); var expected = new NodeId("", context.NamespaceUris.GetIndexOrAppend("http://contoso.com/UA")); var s1 = expected.AsString(context); var s2 = expected.AsString(context, true); var result1 = s1.ToNodeId(context); var result2 = s2.ToNodeId(context); AssertEqual(expected, result1, result2); }
/// <inheritdoc/> public void WriteNodeId(string property, NodeId value) { if (NodeId.IsNull(value)) { WriteNull(property); } else if (UseReversibleEncoding) { if (UseUriEncoding || UseAdvancedEncoding) { WriteString(property, value.AsString(Context)); } else { // Back compat to json encoding WriteString(property, value.ToString()); } } else { PushObject(property); _writer.WritePropertyName("Id"); _writer.WriteValue(new NodeId(value.Identifier, 0).ToString()); WriteNamespaceIndex(value.NamespaceIndex); PopObject(); } }
public void EncodeDecodeNodeIdWithStringAndInvalidUri() { var context = new ServiceMessageContext(); var expected = new NodeId(" space tests /(%)§;#;;#;()§$\"))\"\")(§", context.NamespaceUris.GetIndexOrAppend("contoso")); var s1 = expected.AsString(context); var s2 = expected.AsString(context, true); var result1 = s1.ToNodeId(context); var result2 = s2.ToNodeId(context); Assert.Equal(s1, s2); Assert.Contains("nsu=", s2); Assert.DoesNotContain("ns=", s2); AssertEqual(expected, result1, result2); }
public void EncodeDecodeNodeIdWithNullString() { var context = new ServiceMessageContext(); var expected = new NodeId((string)null, context.NamespaceUris.GetIndexOrAppend("http://contoso.com/UA")); var s1 = expected.AsString(context); var s2 = expected.AsString(context, true); var result1 = s1.ToNodeId(context); var result2 = s2.ToNodeId(context); Assert.Equal(expected, result1); Assert.Equal(expected, result2); Assert.True(Utils.IsEqual(result1, result2)); Assert.Equal(string.Empty, result1.Identifier); Assert.Equal(expected.NamespaceIndex, result1.NamespaceIndex); Assert.Equal(string.Empty, result2.Identifier); Assert.Equal(expected.NamespaceIndex, result2.NamespaceIndex); }