예제 #1
0
        public void UrlEncodingWorks(bool use)
        {
            var ps = new ProtocolSettings().UseUrlEncode(use, use);

            var json = Helper.ReformatJson(Internal.GetProgramsResponseHelperSerializationTests.ValidJsonPlural);

            json = use ? System.Net.WebUtility.UrlEncode(json) : json;

            var value = LikePharmaClient.DeserializeJson <GetProgramsResponse>(json, ps, jsonSerializerOptions);

            Validate(value, "p");

            var newJson = LikePharmaClient.SerializeJson(value, ps, jsonSerializerOptions);

            Assert.Equal(json, newJson);
        }
예제 #2
0
        public void SerializeGetProgramsResponseAutomatically(bool singular, string expectedJson)
        {
            var ps = new ProtocolSettings()
            {
                SingularGetProgramsResponse = singular
            };

            // вместо конструирования просто десериализуем, так проще
            var value = LikePharmaClient.DeserializeJson <GetProgramsResponse>(expectedJson, ps, jsonSerializerOptions);

            Validate(value, singular ? "s" : "p");

            var newJson = LikePharmaClient.SerializeJson(value, ps, jsonSerializerOptions);

            Assert.Equal(Helper.ReformatJson(expectedJson), newJson);
        }