public void DecodeEncodeUInt32ArrayFromVariantJsonStringTypeNull() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { type = "UInt32", body = new uint[] { 123u, 124u, 125u } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new uint[] { 123u, 124u, 125u }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(123u, 124u, 125u), encoded); }
public void DecodeEncodeUInt32FromVariantJsonTokenTypeNull() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { Type = "UInt32", Body = 123u }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(123u); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(123u), encoded); }
public void DecodeEncodeUInt32ArrayFromVariantJsonTokenTypeNull2() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { Type = "UInt32", Body = new uint[0] }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new uint[0]); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(), encoded); }
public void DecodeEncodeInt64FromVariantJsonTokenTypeNullMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { DataType = "Int64", Value = -123 }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(-123L); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(-123L), encoded); }
public void DecodeEncodeInt64ArrayFromVariantJsonTokenTypeVariantMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { dataType = "Int64", value = new long[] { -123, -124, -125 } }); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(new long[] { -123, -124, -125 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(-123L, -124L, -125L), encoded); }
public void DecodeEncodeInt64ArrayFromVariantJsonStringTypeNull() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { type = "Int64", body = new long[] { -123, -124, -125 } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new long[] { -123, -124, -125 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(-123L, -124L, -125L), encoded); }
public void DecodeEncodeUInt32FromVariantJsonTokenTypeNullMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = _serializer.FromObject(new { DataType = "UInt32", Value = 123u }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(123u); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromObject(123u), encoded); }
public void DecodeEncodeUInt32FromVariantJsonStringTypeNull() { var codec = new VariantEncoderFactory().Default; var str = _serializer.SerializeToString(new { Type = "uint32", Body = 123u }).ToString(); var variant = codec.Decode(_serializer.FromObject(str), BuiltInType.Null); var expected = new Variant(123u); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromObject(123u), encoded); }
public void DecodeEncodeUInt32FromVariantJsonStringTypeVariantMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { DataType = "UInt32", Value = 123u }).ToString(); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(123u); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(123u), encoded); }
public void DecodeEncodeUInt32ArrayFromVariantJsonTokenTypeVariantMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { dataType = "UInt32", value = new uint[] { 123u, 124u, 125u } }); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(new uint[] { 123u, 124u, 125u }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(123u, 124u, 125u), encoded); }
public void DecodeEncodeUInt32ArrayFromVariantJsonStringTypeVariant() { var codec = new VariantEncoderFactory().Default; var str = _serializer.SerializeToString(new { Type = "UInt32", Body = new uint[] { 123u, 124u, 125u } }).ToString(); var variant = codec.Decode(_serializer.FromObject(str), BuiltInType.Variant); var expected = new Variant(new uint[] { 123u, 124u, 125u }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromArray(123u, 124u, 125u), encoded); }
public void DecodeEncodeUInt32ArrayFromVariantJsonTokenTypeNull1() { var codec = new VariantEncoderFactory().Default; var str = _serializer.FromObject(new { TYPE = "UINT32", BODY = new uint[] { 123u, 124u, 125u } }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new uint[] { 123u, 124u, 125u }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromArray(123u, 124u, 125u), encoded); }
public void DecodeEncodeSByteArrayFromVariantJsonStringTypeVariant() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { Type = "SByte", Body = new sbyte[] { -123, -124, -125 } }).ToString(); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(new sbyte[] { -123, -124, -125 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray((sbyte)-123, (sbyte)-124, (sbyte)-125), encoded); }
public void DecodeEncodeSByteFromVariantJsonStringTypeVariant() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { Type = "SByte", Body = -123 }).ToString(); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant((sbyte)-123); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(-123), encoded); }
public void DecodeEncodeSByteArrayFromVariantJsonTokenTypeVariant2() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { Type = "SByte", Body = new sbyte[0] }); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(new sbyte[0]); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(), encoded); }
public void DecodeEncodeFloatArrayFromVariantJsonStringTypeNull() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { type = "Float", body = new float[] { -123.123f, 124.124f, 0.0f } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new float[] { -123.123f, 124.124f, 0.0f }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(-123.123f, 124.124f, 0.0f).ToString(Formatting.Indented), encoded.ToString(Formatting.Indented)); }
public void DecodeEncodeFloatFromJValueTypeNullIsDouble() { var codec = new VariantEncoderFactory().Default; var str = new JValue(-123.123f); var variant = codec.Decode(str, BuiltInType.Null); // // TODO: See if we can preserve float precision even though we are passing null! // var expected = new Variant(Convert.ToDouble(str.Value)); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(Convert.ToDouble(str.Value)).ToString(Formatting.Indented), encoded.ToString(Formatting.Indented)); }
public void DecodeEncodeDoubleArrayFromVariantJsonTokenTypeVariantMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { dataType = "Double", value = new double[] { -123.123, 124.124, 0.0 } }); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(new double[] { -123.123, 124.124, 0.0 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(-123.123, 124.124, 0.0).ToString(Formatting.Indented), encoded.ToString(Formatting.Indented)); }
public void DecodeEncodeDoubleFromVariantJsonStringTypeNull() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { Type = "double", Body = -123.123f }).ToString(); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(-123.123); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(-123.123).ToString(Formatting.Indented), encoded.ToString(Formatting.Indented)); }
public void DecodeEncodeDoubleFromVariantJsonStringTypeNull() { var codec = new VariantEncoderFactory().Default; var str = _serializer.SerializeToString(new { Type = "double", Body = -123.123f }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(-123.123); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromObject(-123.123), encoded); }
public void DecodeEncodeDoubleArrayFromVariantJsonTokenTypeNull1() { var codec = new VariantEncoderFactory().Default; var str = _serializer.FromObject(new { TYPE = "DOUBLE", BODY = new double[] { -123.123, 124.124, 0.0 } }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new double[] { -123.123, 124.124, 0.0 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromArray(-123.123, 124.124, 0.0), encoded); }
public void DecodeEncodeFloatFromVariantJsonStringTypeVariantMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = JToken.FromObject(new { DataType = "Float", Value = -123.123f }).ToString(); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(-123.123f); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(-123.123f).ToString(Formatting.Indented), encoded.ToString(Formatting.Indented)); }
public void DecodeEncodeFloatArrayFromVariantJsonTokenTypeVariantMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = _serializer.FromObject(new { dataType = "Float", value = new float[] { -123.123f, 124.124f, 0.0f } }); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(new float[] { -123.123f, 124.124f, 0.0f }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromArray(-123.123f, 124.124f, 0.0f), encoded); }
public void DecodeEncodeFloatFromVariantJsonStringTypeVariantMsftEncoding() { var codec = new VariantEncoderFactory().Default; var str = _serializer.SerializeToString(new { DataType = "Float", Value = -123.123f }); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(-123.123f); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromObject(-123.123f), encoded); }
public void DecodeEncodeDoubleArrayFromVariantJsonStringTypeVariant() { var codec = new VariantEncoderFactory().Default; var str = _serializer.SerializeToString(new { Type = "Double", Body = new double[] { -123.123, 124.124, 0.0 } }); var variant = codec.Decode(str, BuiltInType.Variant); var expected = new Variant(new double[] { -123.123, 124.124, 0.0 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromArray(-123.123, 124.124, 0.0), encoded); }
public void DecodeEncodeFloatArrayFromVariantJsonStringTypeNull() { var codec = new VariantEncoderFactory().Default; var str = _serializer.SerializeToString(new { type = "Float", body = new float[] { -123.123f, 124.124f, 0.0f } }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new float[] { -123.123f, 124.124f, 0.0f }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromArray(-123.123f, 124.124f, 0.0f), encoded); }
public void DecodeEncodeFloatArrayFromVariantJsonTokenTypeNull1() { var codec = new VariantEncoderFactory().Default; var str = _serializer.FromObject(new { TYPE = "FLOAT", BODY = new float[] { -123.123f, 124.124f, 0.0f } }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(new float[] { -123.123f, 124.124f, 0.0f }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromArray(-123.123f, 124.124f, 0.0f), encoded); }
public void DecodeEncodeFloatFromVariantJsonTokenTypeNull() { var codec = new VariantEncoderFactory().Default; var str = _serializer.FromObject(new { Type = "Float", Body = -123.123f }); var variant = codec.Decode(str, BuiltInType.Null); var expected = new Variant(-123.123f); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(_serializer.FromObject(-123.123f), encoded); }
public void EncodeDecodeArgument3() { var codec = new VariantEncoderFactory().Default; var expected = new Variant(new ExtensionObject { Body = new Argument("something3", new NodeId(2364), -1, "dd f s fdd fd") { ArrayDimensions = new uint[0] }.AsBinary(ServiceMessageContext.GlobalContext), TypeId = "http://test.org/i=444445" }); var encoded = codec.Encode(expected); var variant = codec.Decode(encoded, BuiltInType.ExtensionObject); var obj = variant.Value as ExtensionObject; Assert.NotNull(obj); Assert.Equal(ExtensionObjectEncoding.Binary, obj.Encoding); Assert.True(obj.Body is byte[]); Assert.Equal(expected, variant); }
public void EncodeDecodeArgument1() { var codec = new VariantEncoderFactory().Default; var expected = new Variant(new ExtensionObject { Body = new Argument("something1", new NodeId(2354), -1, "somedesciroeioi") { ArrayDimensions = new uint[0] }, TypeId = DataTypeIds.Argument }); var encoded = codec.Encode(expected); var variant = codec.Decode(encoded, BuiltInType.ExtensionObject); var obj = variant.Value as ExtensionObject; Assert.NotNull(obj); Assert.Equal(ExtensionObjectEncoding.EncodeableObject, obj.Encoding); Assert.True(obj.Body is Argument); Assert.Equal(expected, variant); }