//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnUnpackingMapWithDuplicateKeys() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowOnUnpackingMapWithDuplicateKeys() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.PackMapHeader(2); packer.Pack("key"); packer.pack(intValue(1)); packer.Pack("key"); packer.pack(intValue(2)); // When try { PackedInputArray input = new PackedInputArray(output.Bytes()); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input); unpacker.Unpack(); fail("exception expected"); } catch (BoltIOException ex) { assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Duplicate map key `key`."), Neo4jError.from(ex)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailWhenTryingToPackAndUnpackMapContainingNullKeys() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFailWhenTryingToPackAndUnpackMapContainingNullKeys() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); IDictionary <string, AnyValue> map = new Dictionary <string, AnyValue>(); map[null] = longValue(42L); map["foo"] = longValue(1337L); packer.PackMapHeader(map.Count); foreach (KeyValuePair <string, AnyValue> entry in map.SetOfKeyValuePairs()) { packer.pack(entry.Key); packer.pack(entry.Value); } // When try { PackedInputArray input = new PackedInputArray(output.Bytes()); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input); unpacker.Unpack(); fail("exception expected"); } catch (BoltIOException ex) { assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Value `null` is not supported as key in maps, must be a non-nullable string."), Neo4jError.from(ex)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToPackAndUnpackMap() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToPackAndUnpackMap() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.PackMapHeader(ALICE.properties().size()); ALICE.properties().@foreach((s, value) => { try { packer.pack(s); packer.pack(value); } catch (IOException e) { throw new UncheckedIOException(e); } }); AnyValue unpacked = unpacked(output.Bytes()); // Then assertThat(unpacked, instanceOf(typeof(MapValue))); MapValue unpackedMap = ( MapValue )unpacked; assertThat(unpackedMap, equalTo(ALICE.properties())); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private byte[] runMessage(java.util.Map<String,Object> metadata) throws java.io.IOException private sbyte[] RunMessage(IDictionary <string, object> metadata) { PackedOutputArray @out = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = Util.Neo4jPack.newPacker(@out); packer.PackStructHeader(3, RunMessage.SIGNATURE); packer.Pack("RETURN 1"); packer.pack(EMPTY_MAP); packer.pack(asMapValue(metadata)); return(@out.Bytes()); }
private void WriteInit(InitMessage message) { try { Packer.packStructHeader(2, InitMessage.SIGNATURE); Packer.pack(message.UserAgent()); Packer.pack(ValueUtils.asMapValue(message.AuthToken())); } catch (IOException e) { throw new UncheckedIOException(e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private byte[] packMessageWithSignature(byte signature) throws java.io.IOException private sbyte[] PackMessageWithSignature(sbyte signature) { PackedOutputArray @out = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = PackerUnderTest.newPacker(@out); packer.PackStructHeader(2, signature); packer.Pack("RETURN 'Hello World!'"); packer.pack(EMPTY_MAP); return(@out.Bytes()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTreatCharArrayAsListOfStrings() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTreatCharArrayAsListOfStrings() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.pack(charArray(new char[] { 'W', 'H', 'Y' })); object unpacked = unpacked(output.Bytes()); // Then assertThat(unpacked, instanceOf(typeof(ListValue))); assertThat(unpacked, equalTo(VirtualValues.list(stringValue("W"), stringValue("H"), stringValue("Y")))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTreatSingleCharAsSingleCharacterString() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTreatSingleCharAsSingleCharacterString() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.pack(charValue('C')); AnyValue unpacked = unpacked(output.Bytes()); // Then assertThat(unpacked, instanceOf(typeof(TextValue))); assertThat(unpacked, equalTo(stringValue("C"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPackUtf8() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPackUtf8() { // Given string value = "\uD83D\uDE31"; sbyte[] bytes = value.GetBytes(Encoding.UTF8); TextValue textValue = utf8Value(bytes, 0, bytes.Length); PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.pack(textValue); // When AnyValue unpacked = unpacked(output.Bytes()); assertThat(unpacked, @is(instanceOf(typeof(UTF8StringValue)))); // Then assertThat(unpacked, equalTo(textValue)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnUnpackingMapWithUnsupportedKeyType() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowOnUnpackingMapWithUnsupportedKeyType() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.PackMapHeader(2); packer.Pack(ValueUtils.of(1L)); packer.pack(intValue(1)); // When try { PackedInputArray input = new PackedInputArray(output.Bytes()); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input); unpacker.Unpack(); fail("exception expected"); } catch (BoltIOException ex) { assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, "Bad key type: INTEGER"), Neo4jError.from(ex)); } }