コード例 #1
0
        public void ShouldFormatObjectWithAllAttributes()
        {
            var expected = new Dictionary <string, string>
            {
                ["key1"]           = "value1",
                ["key2"]           = "value2",
                ["key3"]           = "value3",
                ["Key4"]           = "value4",
                ["Key5"]           = "value5",
                ["Key7"]           = "value7",
                ["urlId8"]         = "value8",
                ["urlId9"]         = "value9",
                ["jsonProperty10"] = "value10",
                ["urlId11"]        = "value11",
                ["urlId13"]        = "value13",
                ["urlId14"]        = "value14",
            };

            var value = new ObjectWithAllAttributes
            {
                Key1  = "value1",
                Key2  = "value2",
                Key3  = "value3",
                Key4  = "value4",
                Key5  = "value5",
                Key6  = "value6",
                Key7  = "value7",
                Key8  = "value8",
                Key9  = "value9",
                Key10 = "value10",
                Key11 = "value11",
                Key12 = "value12",
                Key13 = "value13",
                Key14 = "value14",
            };

            var formatter = new JsonFormFormatter();

            var result = formatter.Format(value);

            result.ShouldBeEquivalentTo(expected);
        }
コード例 #2
0
        public void ShouldFormatObjectWithDataMemberAttributes()
        {
            var expected = new Dictionary <string, string>
            {
                ["key1"] = "value1",
                ["Key2"] = "value2",
                ["Key3"] = "value3",
                ["Key4"] = "",
            };

            var value = new ObjectWithDataMemberAttributes
            {
                Key1 = "value1",
                Key2 = "value2",
                Key3 = "value3"
            };

            var formatter = new JsonFormFormatter();

            var result = formatter.Format(value);

            result.ShouldBeEquivalentTo(expected);
        }