Exemplo n.º 1
0
        public void If_field_has_JsonProperty_with_name_should_use_it()
        {
            var obj = new ClassWithNameAttribute {
                Value = 123
            };
            var result = FormUrlEncodedSerializer.ToKVPairs(obj);

            result.First().Key.Should().Be("some_name");
        }
Exemplo n.º 2
0
        public void SerializeDecimal(decimal value, string expected)
        {
            var obj = new ClassWithDecimalValue {
                Value = value
            };
            var result = FormUrlEncodedSerializer.ToKVPairs(obj);

            result.First().Value.Should().Be(expected);
        }
Exemplo n.º 3
0
        public void SerializeString(string value)
        {
            var obj = new ClassWithStringValue {
                Value = value
            };
            var result = FormUrlEncodedSerializer.ToKVPairs(obj);

            result.First().Value.Should().Be(value);
        }
Exemplo n.º 4
0
        public void If_field_has_no_JsonProperty_then_should_the_actual_property_name()
        {
            var obj = new ClassWithAttributeButNoName {
                Value = 123
            };
            var result = FormUrlEncodedSerializer.ToKVPairs(obj);

            result.First().Key.Should().Be("Value");
        }
Exemplo n.º 5
0
        private void Should_include_properties_from_base_class()
        {
            var obj = new InheritingClass {
                PropertyInBase = 234
            };
            var result = FormUrlEncodedSerializer.ToKVPairs(obj);

            result.First().Key.Should().Be("PropertyInBase");
            result.First().Value.Should().Be("234");
        }
Exemplo n.º 6
0
        public void Serialize_two_properties()
        {
            var obj = new ClassWithTwoProperties
            {
                Value1 = "abc",
                Value2 = "def"
            };

            var result = FormUrlEncodedSerializer.ToKVPairs(obj);

            var property1 = result.First(kv => kv.Key == "val1");

            property1.Value.Should().Be("abc");

            var property2 = result.First(kv => kv.Key == "val2");

            property2.Value.Should().Be("def");
        }