public static AnyValue Convert(IEnumerable <Notification> notifications) { IList <AnyValue> @out = new List <AnyValue>(); foreach (Notification notification in notifications) { InputPosition pos = notification.Position; // position is optional bool includePosition = !pos.Equals(InputPosition.empty); int size = includePosition ? 5 : 4; MapValueBuilder builder = new MapValueBuilder(size); builder.Add("code", stringValue(notification.Code)); builder.Add("title", stringValue(notification.Title)); builder.Add("description", stringValue(notification.Description)); builder.Add("severity", stringValue(notification.Severity.ToString())); if (includePosition) { // only add the position if it is not empty builder.Add("position", VirtualValues.map(new string[] { "offset", "line", "column" }, new AnyValue[] { intValue(pos.Offset), intValue(pos.Line), intValue(pos.Column) })); } @out.Add(builder.Build()); } return(VirtualValues.fromList(@out)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void testUnpackableStructParametersWithKnownType(org.neo4j.bolt.messaging.Neo4jPack packerForSerialization, org.neo4j.values.AnyValue parameterValue, String expectedMessage) throws Exception private void TestUnpackableStructParametersWithKnownType(Neo4jPack packerForSerialization, AnyValue parameterValue, string expectedMessage) { string statement = "RETURN $x"; MapValue parameters = VirtualValues.map(new string[] { "x" }, new AnyValue[] { parameterValue }); BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); _channel.writeInbound(Unpooled.wrappedBuffer(serialize(packerForSerialization, new RunMessage(statement, parameters)))); _channel.finishAndReleaseAll(); verify(stateMachine).handleExternalFailure(eq(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.TypeError, expectedMessage)), any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSerializeRelationship() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeRelationship() { RelationshipValue rel = relationshipValue(12L, nodeValue(1L, stringArray(), VirtualValues.EMPTY_MAP), nodeValue(2L, stringArray(), VirtualValues.EMPTY_MAP), stringValue("KNOWS"), VirtualValues.map(new string[] { "name", "age" }, new AnyValue[] { stringValue("Bob"), intValue(14) })); assertThat(Serialized(rel), equalTo("B1 71 91 B5 52 0C 01 02 85 4B 4E 4F 57 53 A2 84" + lineSeparator() + "6E 61 6D 65 83 42 6F 62 83 61 67 65 0E")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSerializeNode() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeNode() { NodeValue nodeValue = nodeValue(12L, stringArray("User", "Banana"), VirtualValues.map(new string[] { "name", "age" }, new AnyValue[] { stringValue("Bob"), intValue(14) })); assertThat(Serialized(nodeValue), equalTo("B1 71 91 B3 4E 0C 92 84 55 73 65 72 86 42 61 6E" + lineSeparator() + "61 6E 61 A2 84 6E 61 6D 65 83 42 6F 62 83 61 67" + lineSeparator() + "65 0E")); }
private MapValue SingletonMap(string key, object value) { return(VirtualValues.map(new string[] { key }, new AnyValue[] { ValueUtils.of(value) })); }