Esempio n. 1
0
        public void Should_return_same_value_if_decoding_non_json_field()
        {
            var source = JValue.CreateNull();

            var result = ValueConverters.EncodeJson()(source, stringField);

            Assert.Same(source, result);
        }
Esempio n. 2
0
        public void Should_return_same_value_if_encoding_null_value()
        {
            var source = JValue.CreateNull();

            var result = ValueConverters.EncodeJson()(source, jsonField);

            Assert.Same(source, result);
        }
Esempio n. 3
0
        public void Should_return_same_value_if_encoding_non_json_field()
        {
            var source = (JToken)"NO-JSON";

            var result = ValueConverters.EncodeJson()(source, stringField);

            Assert.Same(source, result);
        }
        public void Should_return_same_value_if_decoding_non_json_field()
        {
            var source = JsonValue.Null;

            var result = ValueConverters.EncodeJson(TestUtils.DefaultSerializer)(source, stringField);

            Assert.Same(source, result);
        }
Esempio n. 5
0
        public void Should_encode_json_value()
        {
            var source = new JObject();

            var result = ValueConverters.EncodeJson()(source, jsonField);

            Assert.Equal("e30=", result);
        }
        public void Should_encode_json_value()
        {
            var source = JsonValue.Object();

            var result = ValueConverters.EncodeJson(TestUtils.DefaultSerializer)(source, jsonField);

            Assert.Equal(JsonValue.Create("e30="), result);
        }
Esempio n. 7
0
 public static IdContentData ToMongoModel(this NamedContentData result, Schema schema, IJsonSerializer serializer)
 {
     return(result.ConvertName2Id(schema,
                                  FieldConverters.ForValues(
                                      ValueConverters.EncodeJson(serializer)),
                                  FieldConverters.ForNestedName2Id(
                                      ValueConverters.EncodeJson(serializer))));
 }
Esempio n. 8
0
        public void Should_convert_for_value_conversion()
        {
            var input =
                new ContentFieldData()
                .AddValue("iv", JsonValue.Object());

            var actual = FieldConverters.ForValues(ValueConverters.EncodeJson(TestUtils.DefaultSerializer))(input, jsonField);

            var expected =
                new ContentFieldData()
                .AddValue("iv", "e30=");

            Assert.Equal(expected, actual);
        }
Esempio n. 9
0
        public DataConverter(IJsonSerializer serializer)
        {
            var decoder = ValueConverters.DecodeJson(serializer);

            decodeJsonConverters = new[]
            {
                FieldConverters.ForValues(decoder, ValueConverters.ForNested(decoder))
            };

            var encoder = ValueConverters.EncodeJson(serializer);

            encodeJsonConverters = new[]
            {
                FieldConverters.ForValues(encoder, ValueConverters.ForNested(encoder))
            };
        }
Esempio n. 10
0
        public void Should_convert_for_value_conversion()
        {
            var field = Fields.Json(1, "json", Partitioning.Invariant);

            var source =
                new ContentFieldData()
                .AddJsonValue(JsonValue.Object());

            var result = FieldConverters.ForValues(ValueConverters.EncodeJson(TestUtils.DefaultSerializer))(source, field);

            var expected =
                new ContentFieldData()
                .AddValue("iv", "e30=");

            Assert.Equal(expected, result);
        }
Esempio n. 11
0
        public DataConverter(IJsonSerializer serializer)
        {
            decodeJsonConverters = new[]
            {
                FieldConverters.ForValues(
                    ValueConverters.DecodeJson(serializer)),
                FieldConverters.ForNestedId2Name(
                    ValueConverters.DecodeJson(serializer))
            };

            encodeJsonConverters = new[]
            {
                FieldConverters.ForValues(
                    ValueConverters.EncodeJson(serializer)),
                FieldConverters.ForNestedName2Id(
                    ValueConverters.EncodeJson(serializer))
            };
        }