public async Task ReturnsQueryStats_WhenInTransaction() { BoltClientTestHelper.GetDriverAndSession(out var mockDriver, out _, out _); bool completedRaised = false; QueryStats stats = null; var client = new BoltGraphClient(mockDriver); client.OperationCompleted += (o, e) => { stats = e.QueryStats; completedRaised = true; }; await client.ConnectAsync(); using (var tx = client.BeginTransaction()) { await client.Cypher.WithQueryStats.Match("n").Return(n => n.Count()).ExecuteWithoutResultsAsync(); completedRaised.Should().BeTrue(); stats.Should().NotBeNull(); } }
public async Task DoesntDoAnything() { BoltClientTestHelper.GetDriverAndSession(out var mockDriver, out _, out _); var client = new BoltGraphClient(mockDriver); await client.ConnectAsync(); using (var tx = client.BeginTransaction()) { await tx.KeepAliveAsync(); } }
public async Task QueryInTransaction_ThrowsExceptionWhen_ExecutingCypherQueryAgainstADifferentDatabaseName() { BoltClientTestHelper.GetDriverAndSession(out var mockDriver, out _, out var mockTransaction); var client = new BoltGraphClient(mockDriver); await client.ConnectAsync(); using (var tx = client.BeginTransaction()) { var ex = Assert.Throws <InvalidOperationException>(() => client.Cypher.WithDatabase("foo").Match("n").Return(n => n.Count())); ex.Should().NotBeNull(); } }
public async Task IsTrueWhen_Open() { BoltClientTestHelper.GetDriverAndSession(out var mockDriver, out _, out _); var client = new BoltGraphClient(mockDriver); await client.ConnectAsync(); using (var tx = client.BeginTransaction()) { await client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResultsAsync(); tx.IsOpen.Should().BeTrue(); } }
public async Task CallsRollsback_IfTransactionIsOpen() { BoltClientTestHelper.GetDriverAndSession(out var mockDriver, out _, out var mockTransaction); var client = new BoltGraphClient(mockDriver); await client.ConnectAsync(); using (var tx = client.BeginTransaction()) { await client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResultsAsync(); } await mockTransaction.Received(1).RollbackAsync(); }
public async Task ThrowsClosedTransactionException_WhenTransactionAlreadyClosed() { BoltClientTestHelper.GetDriverAndSession(out var mockDriver, out _, out var mockTransaction); var client = new BoltGraphClient(mockDriver); await client.ConnectAsync(); using (var tx = client.BeginTransaction()) { await client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResultsAsync(); await tx.CommitAsync(); var ex = await Assert.ThrowsAsync <ClosedTransactionException>(async() => await tx.CommitAsync()); ex.Should().NotBeNull(); } }