Exemple #1
0
        public void ExpandOptions()
        {
            var obj = new BaseOptions();

            obj.AddExpand("example1.subexample1");
            obj.AddExpand("example2");
            obj.AddExpand("example3.subexample3");

            var url = this.service.ApplyAllParameters(obj, string.Empty, false);

            Assert.Equal("?expand[]=example1.subexample1&expand[]=example2&expand[]=example3.subexample3", url);
        }
        public void SerializeAndDeserializeExpandAndExtraParams()
        {
            var options = new BaseOptions();

            options.AddExpand("expand_me");
            options.AddExtraParam("foo", "String!");
            options.AddExtraParam("bar", 234L);

            var json         = JsonConvert.SerializeObject(options);
            var deserialized = JsonConvert.DeserializeObject <BaseOptions>(json);

            Assert.Equal(options.Expand, deserialized.Expand);
            Assert.True(options.ExtraParams.Count == deserialized.ExtraParams.Count);
            Assert.All(
                deserialized.ExtraParams,
                kvp => Assert.Equal(options.ExtraParams[kvp.Key], deserialized.ExtraParams[kvp.Key]));
        }