示例#1
0
        public void Serialize_When_PropertyDecoratedWithScriptIgnoreAttribute_PropertyIsNotAddedToSerialization()
        {
            NullPropertiesConverter   nullPropertiesConverter   = new NullPropertiesConverter();
            ScriptIgnoreAttributeMock scriptIgnoreAttributeMock = new ScriptIgnoreAttributeMock
            {
                Id = 32
            };
            IDictionary <string, object> target = nullPropertiesConverter.Serialize(scriptIgnoreAttributeMock, null);

            target.Should().BeEmpty();
        }
示例#2
0
        public void Serialize_When_PropertyIsNull_PropertyIsNotAddedToSerialization()
        {
            NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter();
            FullCalendarParameters  parameters = new FullCalendarParameters
            {
                EventRenderWait = null
            };
            IDictionary <string, object> target = nullPropertiesConverter.Serialize(parameters, null);

            target.Should().NotContainKey("EventRenderWait");
        }
示例#3
0
        public void Serialize_When_PropertiesAreNotNull_AllOfThemAreAddedToSerialization()
        {
            NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter();
            SerializableValidRange  validRange = new SerializableValidRange
            {
                start = "1:00",
                end   = "2:00"
            };
            IDictionary <string, object> target = nullPropertiesConverter.Serialize(validRange, null);

            target.Should().Contain("start", "1:00");
            target.Should().Contain("end", "2:00");
        }
示例#4
0
        public void Serialize_When_IntegerPropertyIsZero_PropertyIsNotAddedToSerialization()
        {
            NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter();
            Duration duration = new Duration
            {
                Days   = 1,
                Weeks  = 0,
                Months = 2
            };
            IDictionary <string, object> target = nullPropertiesConverter.Serialize(duration, null);

            target.Should().Contain("Days", 1);
            target.Should().Contain("Months", 2);
            target.Should().NotContainKey("Weeks");
        }