public void Should_serialize_DateTimeOffset_as_property_when_using_string_formatting2()
        {
            var mapperSettings = new DynamicObjectMapperSettings {
                FormatNativeTypesAsString = true
            };
            var mapper = new DynamicObjectMapper(mapperSettings);

            var dto1       = new DateTimeOffset(2, 1, 2, 10, 0, 0, 300, new TimeSpan(1, 30, 0));
            var dtoDynamic = mapper.MapObject(dto1);
            var dto2       = mapper.Map <DateTimeOffset>(dtoDynamic);

            dto2.ShouldBe(dto1);
        }
        public void Should_serialize_DateTimeOffset_as_property_when_using_string_formatting2()
        {
            Skip.If(this.TestIs <JsonSerializer>(), "DateTimeOffset not supported by JsonSerializer");

            var mapperSettings = new DynamicObjectMapperSettings {
                FormatNativeTypesAsString = true
            };
            var mapper = new DynamicObjectMapper(mapperSettings);

            var dto1       = new DateTimeOffset(2, 1, 2, 10, 0, 0, 300, new TimeSpan(1, 30, 0));
            var dtoDynamic = mapper.MapObject(dto1);
            var dto2       = mapper.Map <DateTimeOffset>(dtoDynamic);

            dto2.ShouldBe(dto1);
        }
Example #3
0
        public When_created_based_on_object_with_abstract_properties_with_type_information()
        {
            obj = new ClassWithAbstractProperties
            {
                Ref    = new A(),
                Value1 = "the value's pay load",
                Value2 = 222,
                Value3 = new object(),
                Value4 = new byte[] { 1, 22, 0, 44 },
            };

            var mapper = new DynamicObjectMapper();

            dynamicObject = mapper.MapObject(obj);
        }
        public When_mapping_object_to_custom_dynamic_object()
        {
            source = new A
            {
                B = new B
                {
                    C = new C
                    {
                        Int32Value = Int32Value,
                    },
                },
            };

            source.B.A   = source;
            source.B.C.A = source;

            var mapper = new DynamicObjectMapper(dynamicObjectFactory: new DynamicObjectFactory());

            dynamicObject = mapper.MapObject(source);
        }