예제 #1
0
                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();
                    }
                }
예제 #2
0
                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();
                    }
                }
예제 #3
0
            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();
                }
            }
예제 #4
0
                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();
                    }
                }
예제 #5
0
                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();
                }
예제 #6
0
                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();
                    }
                }