コード例 #1
0
            public void should_drecode_correctly_to_static_body()
            {
                var outputStatic = decoder.DecodeToStatic <PlaceResponse <PlaceDetail> >(input,
                                                                                         HttpContentTypes.ApplicationJson);

                Assert.AreEqual("Church Street, Wilmslow, SK9 1, United Kingdom", outputStatic.result.formatted_address);
            }
コード例 #2
0
        public void when_decoding_an_object_with_custom_naming_of_property_should_decode_taking_into_account_custom_property_name()
        {
            var combinedResolverStrategy = new CombinedResolverStrategy(
                new JsonResolverStrategy(),
                new DataContractResolverStrategy(),
                new XmlResolverStrategy(),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.PascalCase),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.CamelCase),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.Lowercase, "-"),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.Uppercase, "_"));

            IEnumerable <IDataReader> readers = new List <IDataReader>
            {
                new JsonReader(new DataReaderSettings(combinedResolverStrategy), HttpContentTypes.ApplicationJson)
            };

            var decoder = new DefaultDecoder(new RegExBasedDataReaderProvider(readers));

            var obj = decoder.DecodeToStatic <CustomNaming>("{\"abc\":\"def\"}", "application/json");

            Assert.AreEqual("def", obj.PropertyName);
        }