public void ShouldSerialize() { var writerMachine = CreateWriterMachine(); var writer = writerMachine.Writer(); writer.Write(new BeginMessage(null, Bookmark.From(SessionTests.FakeABookmark(123)), TimeSpan.FromMinutes(1), new Dictionary <string, object> { { "username", "MollyMostlyWhite" } }, AccessMode.Write)); var readerMachine = CreateReaderMachine(writerMachine.GetOutput()); var reader = readerMachine.Reader(); reader.PeekNextType().Should().Be(PackStream.PackType.Struct); reader.ReadStructHeader().Should().Be(1); reader.ReadStructSignature().Should().Be(BoltProtocolV3MessageFormat.MsgBegin); var metadata = reader.ReadMap(); metadata.Should().HaveCount(3).And.ContainKeys("bookmarks", "tx_timeout", "tx_metadata"); metadata["bookmarks"].CastOrThrow <List <object> >().Should().HaveCount(1).And .Contain("bookmark-123"); metadata["tx_timeout"].Should().Be(60000L); metadata["tx_metadata"].CastOrThrow <Dictionary <string, object> >().Should().HaveCount(1).And.Contain( new[] { new KeyValuePair <string, object>("username", "MollyMostlyWhite"), }); }
public void ShouldSerialize() { var writerMachine = CreateWriterMachine(); var writer = writerMachine.Writer(); var query = new Query("RETURN $x", new Dictionary <string, object> { { "x", 1L } }); writer.Write(new RunWithMetadataMessage(query, "my-database", Bookmark.From(SessionTests.FakeABookmark(123)), TimeSpan.FromMinutes(1), new Dictionary <string, object> { { "username", "MollyMostlyWhite" } }, AccessMode.Write)); var readerMachine = CreateReaderMachine(writerMachine.GetOutput()); var reader = readerMachine.Reader(); reader.PeekNextType().Should().Be(PackStream.PackType.Struct); reader.ReadStructHeader().Should().Be(3); reader.ReadStructSignature().Should().Be(BoltProtocolV3MessageFormat.MsgRun); reader.ReadString().Should().Be("RETURN $x"); reader.ReadMap().Should().HaveCount(1).And.Contain(new KeyValuePair <string, object>("x", 1L)); var metadata = reader.ReadMap(); metadata.Should().BeEquivalentTo( new Dictionary <string, object> { { "bookmarks", new[] { "bookmark-123" } },
public async Task ShouldSyncIfValidBookmarkGiven() { var mockConn = NewConnectionWithMode(); var bookmark = Bookmark.From(SessionTests.FakeABookmark(234)); await BoltV3.BeginTransactionAsync(mockConn.Object, bookmark, null); mockConn.Verify( x => x.EnqueueAsync(It.IsAny <BeginMessage>(), It.IsAny <V1.BeginResponseHandler>(), null, null), Times.Once); mockConn.Verify(x => x.SyncAsync(), Times.Once); }