Esempio n. 1
0
        public void Should_serialize_dynamic_object(Type type, object value)
        {
            SkipUnsupportedDataType(type, value);

            var dynamicObject = new DynamicObjectMapper().MapObject(value);

            var config = CreateModelFor(type);
            var copy   = dynamicObject.Serialize(config);

            copy?.Get().ShouldBe(dynamicObject?.Get(), $"type: {type} value: {value}");

            var c = new DynamicObjectMapper().Map(copy);

            c.ShouldBe(value);
        }
Esempio n. 2
0
        public void Should_serialize_dynamic_object(Type type, object value, CultureInfo culture)
        {
            SkipUnsupportedDataType(type, value);

            using var cultureContext = culture.CreateContext();

            var dynamicObject = new DynamicObjectMapper().MapObject(value);
            var copy          = dynamicObject.Serialize();

            copy?.Get().ShouldBe(dynamicObject?.Get(), $"type: {type} value: {value}");

            var c = new DynamicObjectMapper().Map(copy);

            c.ShouldBe(value);
        }
Esempio n. 3
0
        public void Map_array_as_object_should_set_item_null_for_null_reference()
        {
            var objects = new object[]
            {
                new CustomClass(),
                null,
                new CustomClass(),
            };

            var result = new DynamicObjectMapper().MapObject(objects);

            var array = result.Get <object[]>();

            array.Length.ShouldBe(3);
            array[0].ShouldBeOfType <DynamicObject>();
            array[1].ShouldBeNull();
            array[2].ShouldBeOfType <DynamicObject>();
        }