public void DecodeEncodeBooleanMatrixFromVariantJsonTokenTypeNullMsftEncoding() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { dataType = "Boolean", value = new bool[, , ] { { { true, false, true }, { true, false, true }, { true, false, true } }, { { true, false, true }, { true, false, true }, { true, false, true } }, { { true, false, true }, { true, false, true }, { true, false, true } }, { { true, false, true }, { true, false, true }, { true, false, true } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new bool[, , ] { { { true, false, true }, { true, false, true }, { true, false, true } }, { { true, false, true }, { true, false, true }, { true, false, true } }, { { true, false, true }, { true, false, true }, { true, false, true } }, { { true, false, true }, { true, false, true }, { true, false, true } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void DecodeEncodeInt16MatrixFromVariantJsonTypeVariant() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { type = "Int16", body = new short[, , ] { { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } }, { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } }, { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } }, { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Variant, null); var expected = new Variant(new short[, , ] { { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } }, { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } }, { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } }, { { -123, 124, -125 }, { -123, 124, -125 }, { -123, 124, -125 } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void DecodeEncodeUInt16MatrixFromVariantJsonTokenTypeNullMsftEncoding() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { dataType = "UInt16", value = new ushort[, , ] { { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } }, { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } }, { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } }, { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new ushort[, , ] { { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } }, { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } }, { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } }, { { 123, 124, 125 }, { 123, 124, 125 }, { 123, 124, 125 } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void DecodeEncodeInt64MatrixFromVariantJsonTokenTypeVariantMsftEncoding() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { dataType = "Int64", value = new long[, , ] { { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } }, { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } }, { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } }, { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Variant, null); var expected = new Variant(new long[, , ] { { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } }, { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } }, { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } }, { { 123L, -124L, -125L }, { 123L, -124L, -125L }, { 123L, -124L, -125L } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void DecodeEncodeUInt64MatrixFromVariantJsonTypeNull() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { type = "UInt64", body = new ulong[, , ] { { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } }, { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } }, { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } }, { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new ulong[, , ] { { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } }, { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } }, { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } }, { { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu }, { 123Lu, 124Lu, 125Lu } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void DecodeEncodeDoubleMatrixFromVariantJsonTypeVariant() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { type = "Double", body = new double[, , ] { { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } }, { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } }, { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } }, { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Variant, null); var expected = new Variant(new double[, , ] { { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } }, { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } }, { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } }, { { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 }, { 123.456, 124.567, 125.0 } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void DecodeEncodeFloatMatrixFromVariantJsonTokenTypeNullMsftEncoding() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { dataType = "Float", value = new float[, , ] { { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } }, { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } }, { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } }, { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new float[, , ] { { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } }, { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } }, { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } }, { { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f }, { -123.456f, 124.567f, -125.0f } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void DecodeEncodeStringMatrixFromVariantJsonTokenTypeNullMsftEncoding() { var codec = new JsonVariantEncoder(); var str = JToken.FromObject(new { dataType = "String", value = new string[, , ] { { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } }, { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } }, { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } }, { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } } } }).ToString(); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new string[, , ] { { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } }, { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } }, { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } }, { { "test", "zhf", "33" }, { "test", "zhf", "33" }, { "test", "zhf", "33" } } }); var encoded = codec.Encode(variant); Assert.True(expected.Value is Matrix); Assert.True(variant.Value is Matrix); Assert.Equal(((Matrix)expected.Value).Elements, ((Matrix)variant.Value).Elements); Assert.Equal(((Matrix)expected.Value).Dimensions, ((Matrix)variant.Value).Dimensions); }
public void EncodeDecodeLocalizedText() { var codec = new JsonVariantEncoder(); var expected = new Variant(new LocalizedText("en-US", "text")); var encoded = codec.Encode(expected); var variant = codec.Decode(encoded, BuiltInType.LocalizedText, null); Assert.Equal(expected, variant); }
public void EncodeDecodeLocalizedTextFromString2() { var codec = new JsonVariantEncoder(); var str = "text"; var expected = new Variant(new LocalizedText("text")); var variant = codec.Decode(str, BuiltInType.LocalizedText, null); var encoded = codec.Encode(expected); Assert.Equal(expected, variant); }
public void DecodeEncodeIntArray2() { var codec = new JsonVariantEncoder(); var str = "[1,2,3,4,5,6]"; var variant = codec.Decode(str, BuiltInType.Int32, null); var expected = new Variant(new int[] { 1, 2, 3, 4, 5, 6 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); }
public void DecodeEncodeStringArray() { var codec = new JsonVariantEncoder(); var str = "\"test1\", \"test2\""; var variant = codec.Decode(str, BuiltInType.String, null); var expected = new Variant(new string[] { "test1", "test2" }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); }
public void DecodeEncodeStringArrayFromStringTypeNullIsNull() { var codec = new JsonVariantEncoder(); var str = "[]"; var variant = codec.Decode(str, BuiltInType.Null, null); var expected = Variant.Null; var encoded = codec.Encode(variant); Assert.Equal(expected, variant); }
public void DecodeEncodeStringArrayFromQuotedString2() { var codec = new JsonVariantEncoder(); var str = " [\"test\",'test',\"test\"] "; var variant = codec.Decode(str, BuiltInType.String, null); var expected = new Variant(new string[] { "test", "test", "test" }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray("test", "test", "test"), encoded); }
public void DecodeEncodeStringFromQuotedString2() { var codec = new JsonVariantEncoder(); var str = "\"\\\"test\\\"\""; var variant = codec.Decode(str, BuiltInType.String, null); var expected = new Variant("\"test\""); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal("\"test\"", encoded); }
public void DecodeEncodeStringArrayFromStringTypeNullIsString3() { var codec = new JsonVariantEncoder(); var str = "[test, test, test]"; var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new string[] { "[test", "test", "test]" }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray("[test", "test", "test]"), encoded); }
public void DecodeEncodeStringArrayFromString4() { var codec = new JsonVariantEncoder(); var str = "[]"; var variant = codec.Decode(str, BuiltInType.String, null); var expected = new Variant(new string[0]); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(), encoded); }
public void DecodeEncodeStringArrayFromString2() { var codec = new JsonVariantEncoder(); var str = "[123, 124, 125]"; var variant = codec.Decode(str, BuiltInType.String, null); var expected = new Variant(new string[] { "123", "124", "125" }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray("123", "124", "125"), encoded); }
public void DecodeEncodeBooleanFromString() { var codec = new JsonVariantEncoder(); var str = "true"; var variant = codec.Decode(str, BuiltInType.Boolean, null); var expected = new Variant(true); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(true), encoded); }
public void DecodeEncodeUInt16FromString() { var codec = new JsonVariantEncoder(); var str = "123"; var variant = codec.Decode(str, BuiltInType.UInt16, null); var expected = new Variant((ushort)123); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(123), encoded); }
public void DecodeEncodeInt16ArrayFromString() { var codec = new JsonVariantEncoder(); var str = "-123, -124, -125"; var variant = codec.Decode(str, BuiltInType.Int16, null); var expected = new Variant(new short[] { -123, -124, -125 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray((short)-123, (short)-124, (short)-125), encoded); }
public void DecodeEncodeUInt16ArrayFromJArrayTypeNullIsInt64() { var codec = new JsonVariantEncoder(); var str = new JArray((ushort)123, (ushort)124, (ushort)125); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new long[] { 123, 124, 125 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(str, encoded); }
public void DecodeEncodeStringFromString() { var codec = new JsonVariantEncoder(); var str = "123"; var variant = codec.Decode(str, BuiltInType.String, null); var expected = new Variant("123"); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue("123"), encoded); }
public void DecodeEncodeUInt16FromStringTypeIntegerIsInt64() { var codec = new JsonVariantEncoder(); var str = "123"; var variant = codec.Decode(str, BuiltInType.Integer, null); var expected = new Variant(123L); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(123), encoded); }
public void DecodeEncodeStringArrayFromJArrayTypeNullIsString() { var codec = new JsonVariantEncoder(); var str = new JArray("", "", ""); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(new string[] { "", "", "" }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(str, encoded); }
public void DecodeEncodeUInt16ArrayFromString2() { var codec = new JsonVariantEncoder(); var str = "[123, 124, 125]"; var variant = codec.Decode(str, BuiltInType.UInt16, null); var expected = new Variant(new ushort[] { 123, 124, 125 }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray((ushort)123, (ushort)124, (ushort)125), encoded); }
public void DecodeEncodeUInt16ArrayFromStringTypeNumberIsInt642() { var codec = new JsonVariantEncoder(); var str = "[]"; var variant = codec.Decode(str, BuiltInType.Number, null); var expected = new Variant(new Variant[0]); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(), encoded); }
public void DecodeEncodeBooleanArrayFromString2() { var codec = new JsonVariantEncoder(); var str = "[true, true, false]"; var variant = codec.Decode(str, BuiltInType.Boolean, null); var expected = new Variant(new bool[] { true, true, false }); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JArray(true, true, false), encoded); }
public void DecodeEncodeStringFromString3() { var codec = new JsonVariantEncoder(); var str = "[test, test, test]"; var variant = codec.Decode(str, BuiltInType.String, null); var expected = new Variant(str); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(str, encoded); }
public void DecodeEncodeUInt16FromJValueTypeNullIsInt64() { var codec = new JsonVariantEncoder(); var str = new JValue(123); var variant = codec.Decode(str, BuiltInType.Null, null); var expected = new Variant(123L); var encoded = codec.Encode(variant); Assert.Equal(expected, variant); Assert.Equal(new JValue(123), encoded); }