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)); }
public void should_not_include_NotSerialized_fields() { TestMappable tm = new TestMappable(); Dictionary<Object, Object> map = tm.toMap(); Assert.IsFalse(map.ContainsKey("a_transient_int")); }
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")); }
public void should_include_mappable() { TestMappable tm = new TestMappable(); Dictionary <Object, Object> map = tm.toMap(); Assert.IsTrue(map.ContainsKey("a_mappable")); }
public void should_include_mappable() { TestMappable tm = new TestMappable(); Dictionary<Object, Object> map = tm.toMap(); Assert.IsTrue(map.ContainsKey("a_mappable")); }
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")); }
public void should_not_include_NotSerialized_fields() { TestMappable tm = new TestMappable(); Dictionary <Object, Object> map = tm.toMap(); Assert.IsFalse(map.ContainsKey("a_transient_int")); }
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)); }
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()); }
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()); }