public async Task ShouldNotSyncIfBookmarkIsNull() { var mockConn = new Mock <IConnection>(); await BoltV3.BeginTransactionAsync(mockConn.Object, null, null); mockConn.Verify(x => x.Enqueue(It.IsAny <BeginMessage>(), It.IsAny <IMessageResponseCollector>(), null), Times.Once); mockConn.Verify(x => x.SyncAsync(), Times.Never); }
public async Task ShouldSyncIfValidBookmarkGiven() { var mockConn = new Mock <IConnection>(); var bookmark = Bookmark.From(FakeABookmark(234)); await BoltV3.BeginTransactionAsync(mockConn.Object, bookmark, null); mockConn.Verify(x => x.Enqueue(It.IsAny <BeginMessage>(), It.IsAny <IMessageResponseCollector>(), null), Times.Once); mockConn.Verify(x => x.SyncAsync(), Times.Once); }
public async Task ShouldNotSyncIfBookmarkIsNull() { var mockConn = NewConnectionWithMode(); await BoltV3.BeginTransactionAsync(mockConn.Object, null, null); mockConn.Verify( x => x.EnqueueAsync(It.IsAny <BeginMessage>(), It.IsAny <V1.BeginResponseHandler>(), null, null), Times.Once); mockConn.Verify(x => x.SyncAsync(), Times.Never); }
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); }
public async Task ShouldNotSyncIfInvalidBookmarkGiven() { var mockConn = NewConnectionWithMode(); var bookmark = Bookmark.From((string)null); 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.Never); }
public async Task ShouldPassBookmarkAndTxConfigToRunWithMetadataMessage() { var mockConn = new Mock <IConnection>(); mockConn.Setup(x => x.Enqueue(It.IsAny <BeginMessage>(), It.IsAny <ResultBuilder>(), null)) .Callback <IRequestMessage, IMessageResponseCollector, IRequestMessage>( (m0, r, m1) => { var msg = m0.CastOrThrow <BeginMessage>(); VerifyMetadata(msg.Metadata); }); await BoltV3.BeginTransactionAsync(mockConn.Object, Bookmark, TxConfig); mockConn.Verify(x => x.Enqueue(It.IsAny <BeginMessage>(), It.IsAny <ResultBuilder>(), null), Times.Once); }
public async Task ShouldPassBookmarkTxConfigAndModeToRunWithMetadataMessage(AccessMode mode) { var mockConn = NewConnectionWithMode(mode); mockConn.Setup(x => x.EnqueueAsync(It.IsAny <BeginMessage>(), It.IsAny <V1.BeginResponseHandler>(), null, null)) .Returns(TaskHelper.GetCompletedTask()) .Callback <IRequestMessage, IResponseHandler, IRequestMessage, IResponseHandler>( (m1, h1, m2, h2) => { var msg = m1.CastOrThrow <BeginMessage>(); VerifyMetadata(msg.Metadata, mode); }); await BoltV3.BeginTransactionAsync(mockConn.Object, Bookmark, TxConfig); mockConn.Verify( x => x.EnqueueAsync(It.IsAny <BeginMessage>(), It.IsAny <V1.BeginResponseHandler>(), null, null), Times.Once); }