Example #1
0
        public void should_only_include_primitives_strings_mappables_and_collections_of_mappable()
        {
            TestMappable tm = new TestMappable();
            Dictionary<Object, Object> map = tm.toMap();

            String expected = "" +
                    "{\n" +
                    "  \"an_int\":1,\n" +
                    "  \"a_long\":2,\n" +
                    "  \"a_string\":\"3\",\n" +
                    "  \"a_mappable\":{\n" +
                    "    \"another_int\":4,\n" +
                    "    \"a_byte\":5\n" +
                    "  },\n" +
                    "  \"a_short_list\":[\n" +
                    "    4,\n" +
                    "    5,\n" +
                    "    6\n" +
                    "  ],\n" +
                    "  \"a_mappable_list\":[\n" +
                    "    {\n" +
                    "      \"another_int\":4,\n" +
                    "      \"a_byte\":5\n" +
                    "    }\n" +
                    "  ]\n" +
                    "}\n";

            var serializedMap = JsonConvert.SerializeObject(map, new KeyValuePairConverter());

            Assert.AreEqual(RemoveWhiteSpaces(expected), RemoveWhiteSpaces(serializedMap));
        }
Example #2
0
        public void should_not_include_NotSerialized_fields()
        {
            TestMappable tm = new TestMappable();
            Dictionary<Object, Object> map = tm.toMap();

            Assert.IsFalse(map.ContainsKey("a_transient_int"));
        }
Example #3
0
        public void should_not_include_object_fields()
        {
            TestMappable tm = new TestMappable();
            Dictionary<Object, Object> map = tm.toMap();

            Assert.IsFalse(map.ContainsKey("an_int_declared_as_object"));
        }
Example #4
0
        public void should_include_mappable()
        {
            TestMappable tm = new TestMappable();
            Dictionary <Object, Object> map = tm.toMap();

            Assert.IsTrue(map.ContainsKey("a_mappable"));
        }
Example #5
0
        public void should_include_mappable()
        {
            TestMappable tm = new TestMappable();
            Dictionary<Object, Object> map = tm.toMap();

            Assert.IsTrue(map.ContainsKey("a_mappable"));
        }
Example #6
0
        public void should_not_include_object_fields()
        {
            TestMappable tm = new TestMappable();
            Dictionary <Object, Object> map = tm.toMap();

            Assert.IsFalse(map.ContainsKey("an_int_declared_as_object"));
        }
Example #7
0
        public void should_not_include_NotSerialized_fields()
        {
            TestMappable tm = new TestMappable();
            Dictionary <Object, Object> map = tm.toMap();

            Assert.IsFalse(map.ContainsKey("a_transient_int"));
        }
Example #8
0
        public void should_only_include_primitives_strings_mappables_and_collections_of_mappable()
        {
            TestMappable tm = new TestMappable();
            Dictionary <Object, Object> map = tm.toMap();

            String expected = "" +
                              "{\n" +
                              "  \"an_int\":1,\n" +
                              "  \"a_long\":2,\n" +
                              "  \"a_string\":\"3\",\n" +
                              "  \"a_mappable\":{\n" +
                              "    \"another_int\":4,\n" +
                              "    \"a_byte\":5\n" +
                              "  },\n" +
                              "  \"a_short_list\":[\n" +
                              "    4,\n" +
                              "    5,\n" +
                              "    6\n" +
                              "  ],\n" +
                              "  \"a_mappable_list\":[\n" +
                              "    {\n" +
                              "      \"another_int\":4,\n" +
                              "      \"a_byte\":5\n" +
                              "    }\n" +
                              "  ]\n" +
                              "}\n";

            var serializedMap = JsonConvert.SerializeObject(map, new KeyValuePairConverter());

            Assert.AreEqual(RemoveWhiteSpaces(expected), RemoveWhiteSpaces(serializedMap));
        }
Example #9
0
        public void should_include_collection_of_primitives()
        {
            TestMappable tm = new TestMappable();
            Dictionary<Object, Object> map = tm.toMap();

            var shortList = (IEnumerable<object>)map["a_short_list"];

            Assert.IsNotNull(shortList);
            Assert.AreEqual(3, shortList.Count());
        }
Example #10
0
        public void should_include_collection_of_primitives()
        {
            TestMappable tm = new TestMappable();
            Dictionary <Object, Object> map = tm.toMap();

            var shortList = (IEnumerable <object>)map["a_short_list"];

            Assert.IsNotNull(shortList);
            Assert.AreEqual(3, shortList.Count());
        }