public void ShouldPackBytes() { var outputStreamMock = new Mock <IChunkedOutputStream>(); var writer = new PackStreamMessageFormatV1.WriterV1(outputStreamMock.Object); var converter = new BigEndianTargetBitConverter(); var value = new byte[0]; outputStreamMock.Setup(x => x.Write(It.IsAny <byte[]>())).Callback((byte[] data) => value = data); var byteArray = converter.GetBytes("hello, world"); writer.PackValue(byteArray); converter.ToString(value).Should().Be("hello, world"); }
public void ShouldNotPackBytes() { // Given var converter = new BigEndianTargetBitConverter(); byte[] byteArray = converter.GetBytes("hello, world"); // When using (var driver = GraphDatabase.Driver("bolt://127.0.0.1:7687", AuthToken)) using (var session = driver.Session()) { var exception = Record.Exception(() => session.Run("CREATE (a {value:{value}})", new Dictionary <string, object> { { "value", byteArray } })); // Then exception.Should().BeOfType <ProtocolException>(); exception.Message.Should().Be("Cannot understand value with type System.Byte[]"); } }
public void ShouldPackAndUnpackBytes() { // Given var converter = new BigEndianTargetBitConverter(); byte[] byteArray = converter.GetBytes("hello, world"); // When using (var driver = GraphDatabase.Driver("bolt://127.0.0.1:7687", AuthToken)) using (var session = driver.Session()) { var result = session.Run( "CREATE (a {value:{value}}) RETURN a.value", new Dictionary <string, object> { { "value", byteArray } }); // Then foreach (var record in result) { var value = record["a.value"].ValueAs <byte[]>(); value.Should().BeEquivalentTo(byteArray); } } }