public BoltNeo4jTransaction(ISession session, Neo4j.Driver.V1.ITransaction transaction) { DriverTransaction = transaction; Session = session; IsOpen = true; Id = Guid.NewGuid(); }
public BoltNeo4jTransaction(IDriver driver, bool isWrite = true) { Session = driver.Session(isWrite ? AccessMode.Write : AccessMode.Read); DriverTransaction = Session.BeginTransaction(); IsOpen = true; Id = Guid.NewGuid(); }
public BoltNeo4jTransaction(IDriver driver, IEnumerable <string> bookmarks, bool isWrite = true) { Bookmarks = bookmarks?.ToList(); Session = driver.Session(isWrite ? AccessMode.Write : AccessMode.Read, Bookmarks); DriverTransaction = Session.BeginTransaction(); IsOpen = true; Id = Guid.NewGuid(); }
private static void GetAndConnectGraphClient(out IGraphClient graphClient, out IDriver driver, out ISession session, out Neo4j.Driver.V1.ITransaction transaction) { GetDriverAndSession(out driver, out session, out transaction); var client = new BoltGraphClient(driver); client.Connect(); driver.ClearReceivedCalls(); session.ClearReceivedCalls(); graphClient = client; }
private static void GetDriverAndSession(out IDriver driver, out ISession session, out Neo4j.Driver.V1.ITransaction transaction) { var mockNode = Substitute.For <INode>(); mockNode["Name"].Returns("Value"); mockNode.Labels.Returns(new List <string>() { "Node" }); mockNode.Properties.Returns(new Dictionary <string, object>() { { "Name", "Value" } }); var mockRecord = Substitute.For <IRecord>(); mockRecord.Keys.Returns(new List <string>() { "Node" }); mockRecord["Node"].Returns(mockNode); mockRecord.Values["Node"].Returns(mockNode); var mockStatementResult = Substitute.For <IStatementResult>(); mockStatementResult.GetEnumerator().Returns(new List <IRecord>(new[] { mockRecord }).GetEnumerator()); var mockTransaction = Substitute.For <Neo4j.Driver.V1.ITransaction>(); mockTransaction.Run(Arg.Any <string>(), Arg.Any <IDictionary <string, object> >()).Returns(mockStatementResult); var mockSession = Substitute.For <ISession>(); var dbmsReturn = GetDbmsComponentsResponse(); mockSession.Run("CALL dbms.components()").Returns(dbmsReturn); mockSession.BeginTransaction().Returns(mockTransaction); var mockDriver = Substitute.For <IDriver>(); mockDriver.Session().Returns(mockSession); mockDriver.Session(Arg.Any <AccessMode>()).Returns(mockSession); mockDriver.Uri.Returns(new Uri("bolt://localhost")); driver = mockDriver; session = mockSession; transaction = mockTransaction; }
private static void GetDriverAndSession(out IDriver driver, out ISession session, out Neo4j.Driver.V1.ITransaction transaction) { var mockTransaction = Substitute.For <Neo4j.Driver.V1.ITransaction>(); var mockSession = Substitute.For <ISession>(); var dbmsReturn = GetDbmsComponentsResponse(); mockSession.Run("CALL dbms.components()").Returns(dbmsReturn); mockSession.BeginTransaction().Returns(mockTransaction); var mockDriver = Substitute.For <IDriver>(); mockDriver.Session().Returns(mockSession); mockDriver.Session(Arg.Any <AccessMode>()).Returns(mockSession); mockDriver.Uri.Returns(new Uri("bolt://localhost")); driver = mockDriver; session = mockSession; transaction = mockTransaction; }