public void DeepUpdateParents()
        {
            System.Reflection.Assembly assembly = typeof(IDictionaryExtensionTest).Assembly;
            IDictionary data = new Reader().Read <IDictionary>(assembly.FindManifestResourceStream("Object.Coverage.json"));

            Assert.NotNull(data, nameof(data));
            data.DeepUpdateParents();
            IDictionaryExtension.DeepUpdateParents(null);
            data.ComputeHashCode();
        }
Esempio n. 2
0
        public void GetValueOrDefault_of_int_dictionary_is_correct()
        {
            var dict = new Dictionary <int, int>
            {
                { 1, 10 },
                { 2, 20 },
                { 3, 30 }
            };

            dict.GetValueOrDefault(1).ShouldBe(10);
            dict.GetValueOrDefault(4).ShouldBe(0);
            IDictionaryExtension.GetValueOrDefault(dict, 5, -1).ShouldBe(-1);
        }
Esempio n. 3
0
        public void GetValueOrDefault_of_string_dictionary_is_correct()
        {
            var dict = new Dictionary <int, string>
            {
                { 1, "first" },
                { 2, "second" },
                { 3, "third" }
            };

            dict.GetValueOrDefault(1).ShouldBe("first");
            dict.GetValueOrDefault(4).ShouldBeNull();
            IDictionaryExtension.GetValueOrDefault(dict, 5, "five").ShouldBe("five");
        }
        public void ToPostFormString()
        {
            var foo = new Foo {
                A = 1, B = "hello"
            };

            dynamic obj = new ExpandoObject();

            obj.A = foo.A;
            obj.B = foo.B;

            var formData = IDictionaryExtension.ToPostString(obj, null);

            Assert.Equal(formData, $"A={foo.A}&B={foo.B}");
        }
        public void ToPostJsonString()
        {
            var foo = new Foo {
                A = 1, B = "hello"
            };

            dynamic obj = new ExpandoObject();

            obj.A = foo.A;
            obj.B = foo.B;

            var json = IDictionaryExtension.ToPostString(obj, "application/json");

            Assert.Equal(json, JsonConvert.SerializeObject(foo));
        }
Esempio n. 6
0
 public string ToJson()
 {
     return(IDictionaryExtension.ToJson(this));
 }