Exemple #1
0
        public void Convert_Dictionary_FooObject()
        {
            // arrange
            var baz = new Dictionary <string, object>();

            baz["Number"] = "1.5";

            var bar = new Dictionary <string, object>();

            bar["State"] = "On";
            bar["Bazs"]  = new List <object> {
                baz
            };

            var foo = new Dictionary <string, object>();

            foo["text"] = "abc";
            foo["BAR"]  = bar;

            // assert
            var converter = new DictionaryToObjectConverter(
                DefaultTypeConverter.Default);
            object converted = converter.Convert(foo, typeof(Foo));

            // assert
            converted.MatchSnapshot();
        }
Exemple #2
0
        public void Convert_Dictionary_BarObjectWithArray()
        {
            // arrange
            var baz = new Dictionary <string, object>();

            baz["Number"] = "1.5";

            var bar = new Dictionary <string, object>();

            bar["State"] = "On";
            bar["Bazs"]  = new List <object> {
                baz
            };
            bar["BazArray"] = new List <object> {
                baz
            };
            bar["StringArray"] = new List <object> {
                "a", 1, true
            };

            // assert
            var converter = new DictionaryToObjectConverter(
                DefaultTypeConverter.Default);
            object converted = converter.Convert(bar, typeof(Bar));

            // assert
            converted.MatchSnapshot();
        }
Exemple #3
0
        public void Convert_List_ListOfBar()
        {
            // arrange
            var baz = new Dictionary <string, object>();

            baz["Number"] = "1.5";

            var bar = new Dictionary <string, object>();

            bar["State"] = "On";
            bar["Bazs"]  = new List <object> {
                baz
            };
            bar["BazArray"] = new List <object> {
                baz
            };
            bar["StringArray"] = new List <object> {
                "a", 1, true
            };

            var list = new List <object> {
                bar
            };

            // assert
            var converter = new DictionaryToObjectConverter(
                DefaultTypeConverter.Default);
            object converted = converter.Convert(
                list, typeof(ICollection <Bar>));

            // assert
            converted.MatchSnapshot();
        }
Exemple #4
0
        public void Convert_String_Int()
        {
            // arrange
            var input = "1";

            // assert
            var converter = new DictionaryToObjectConverter(
                DefaultTypeConverter.Default);
            object converted = converter.Convert(
                input, typeof(int));

            // assert
            converted.MatchSnapshot();
        }