//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSerializeMapsWithNullKeys() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeMapsWithNullKeys() { object[] values = new object[] { null, "string", 42, true, new string[] { "a string", "another string" }, new int[] { 42, 87 }, new bool[] { true, false }, asList(true, false, true), map("numbers", 42, null, "something"), map("a list", asList(42, 87), null, asList("a", "b")), asList(map("foo", "bar", null, false)) }; foreach (object value in values) { MapRepresentation rep = new MapRepresentation(map(( object )null, value)); OutputFormat format = new OutputFormat(new JsonFormat(), new URI("http://localhost/"), null); string serializedMap = format.Assemble(rep); IDictionary <string, object> map = JsonHelper.jsonToMap(serializedMap); assertEquals(1, map.Count); object actual = map["null"]; if (value == null) { assertNull(actual); } else { assertNotNull(actual); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canProvideJsonOutputFormat() public virtual void CanProvideJsonOutputFormat() { OutputFormat format = _repository.outputFormat(new IList <MediaType> { MediaType.APPLICATION_JSON_TYPE }, null, null); assertNotNull(format); assertEquals("\"test\"", format.Assemble(ValueRepresentation.String("test"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldSerializeArbitrarilyNestedMapsAndLists() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeArbitrarilyNestedMapsAndLists() { MapRepresentation rep = new MapRepresentation(map("a map with a list in it", map("a list", asList(42, 87)), "a list with a map in it", asList(map("foo", "bar", "baz", false)))); OutputFormat format = new OutputFormat(new JsonFormat(), new URI("http://localhost/"), null); string serializedMap = format.Assemble(rep); IDictionary <string, object> map = JsonHelper.jsonToMap(serializedMap); assertThat(((System.Collections.IDictionary)map["a map with a list in it"])["a list"], @is(asList(42, 87))); assertThat(((System.Collections.IDictionary)((System.Collections.IList)map["a list with a map in it"])[0])["foo"], @is("bar")); assertThat(((System.Collections.IDictionary)((System.Collections.IList)map["a list with a map in it"])[0])["baz"], @is(false)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldSerializeMapWithListsOfSimpleTypes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeMapWithListsOfSimpleTypes() { MapRepresentation rep = new MapRepresentation(map("lists of nulls", asList(null, null), "lists of strings", asList("a string", "another string"), "lists of numbers", asList(23, 87, 42), "lists of booleans", asList(true, false, true))); OutputFormat format = new OutputFormat(new JsonFormat(), new URI("http://localhost/"), null); string serializedMap = format.Assemble(rep); IDictionary <string, object> map = JsonHelper.jsonToMap(serializedMap); assertThat(map["lists of nulls"], @is(asList(null, null))); assertThat(map["lists of strings"], @is(asList("a string", "another string"))); assertThat(map["lists of numbers"], @is(asList(23, 87, 42))); assertThat(map["lists of booleans"], @is(asList(true, false, true))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldSerializeMapWithArrayTypes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeMapWithArrayTypes() { MapRepresentation rep = new MapRepresentation(map("strings", new string[] { "a string", "another string" }, "numbers", new int[] { 42, 87 }, "booleans", new bool[] { true, false }, "Booleans", new bool?[] { TRUE, FALSE })); OutputFormat format = new OutputFormat(new JsonFormat(), new URI("http://localhost/"), null); string serializedMap = format.Assemble(rep); IDictionary <string, object> map = JsonHelper.jsonToMap(serializedMap); assertThat(map["strings"], @is(asList("a string", "another string"))); assertThat(map["numbers"], @is(asList(42, 87))); assertThat(map["booleans"], @is(asList(true, false))); assertThat(map["Booleans"], @is(asList(true, false))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSerializeMapWithSimpleTypes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeMapWithSimpleTypes() { MapRepresentation rep = new MapRepresentation(map("nulls", null, "strings", "a string", "numbers", 42, "booleans", true)); OutputFormat format = new OutputFormat(new JsonFormat(), new URI("http://localhost/"), null); string serializedMap = format.Assemble(rep); IDictionary <string, object> map = JsonHelper.jsonToMap(serializedMap); assertThat(map["nulls"], @is(nullValue())); assertThat(map["strings"], @is("a string")); assertThat(map["numbers"], @is(42)); assertThat(map["booleans"], @is(true)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.Map<String, Object> serializeToStringThenParseAsToMap(CypherResultRepresentation repr) throws Exception private IDictionary <string, object> SerializeToStringThenParseAsToMap(CypherResultRepresentation repr) { OutputFormat format = new OutputFormat(new JsonFormat(), new URI("http://localhost/"), null); return(jsonToMap(format.Assemble(repr))); }