public void Instantiate_OneParameterWithTypeStringWithDollarSymbol_CorrectResultSet()
        {
            var conn       = new BoltClient("127.0.0.1", "7687", "neo4j", "bolt");
            var paramActor = new Mock <IQueryParameter>();

            paramActor.SetupGet(x => x.Name).Returns("$actorName");
            paramActor.Setup(x => x.GetValue()).Returns("Tom Hanks");

            var query = Mock.Of <IQuery>(
                x => x.Statement == "MATCH (tom:Person {name: $actorName})-[:ACTED_IN]->(tomHanksMovies) WHERE tomHanksMovies.released>2000 RETURN tomHanksMovies.title, tomHanksMovies.released" &&
                x.Parameters == new List <IQueryParameter>()
            {
                paramActor.Object
            }
                );
            var factory   = new BoltCommandFactory();
            var cmd       = factory.Instantiate(conn, query).Implementation;
            var statement = cmd as Driver.Statement;

            var session = conn.CreateSession();
            var results = session.Run(statement);

            Assert.That(results.Count, Is.EqualTo(4));
            Assert.That(results.Keys.Count(), Is.EqualTo(2));
        }
        public void CanHandle_OtherKindOfSession_False()
        {
            var session = Mock.Of <IClient>();
            var query   = Mock.Of <IQuery>();
            var factory = new BoltCommandFactory();

            Assert.That(factory.CanHandle(session), Is.False);
        }
        public void CanHandle_BoltSession_True()
        {
            var session = new BoltClient("host", "7687", "login", "p@ssw0rd");
            var query   = Mock.Of <IQuery>();
            var factory = new BoltCommandFactory();

            Assert.That(factory.CanHandle(session), Is.True);
        }
        public void Instantiate_BoltSession_NotNull()
        {
            var session = new BoltClient("host", "7687", "login", "p@ssw0rd");
            var query   = Mock.Of <IQuery>();
            var factory = new BoltCommandFactory();
            var command = factory.Instantiate(session, query);

            Assert.That(command, Is.Not.Null);
        }
        public void Instantiate_BoltSession_SessionCorrectType()
        {
            var session = new BoltClient("host", "7687", "login", "p@ssw0rd");
            var query   = Mock.Of <IQuery>();
            var factory = new BoltCommandFactory();
            var command = factory.Instantiate(session, query);
            var impl    = command.Client;

            Assert.That(impl, Is.Not.Null);
            Assert.That(impl, Is.InstanceOf <Driver.ISession>());
        }
        public void Instantiate_NoParameter_CorrectResultSet()
        {
            var conn  = new BoltClient("127.0.0.1", "7687", "neo4j", "bolt");
            var query = Mock.Of <IQuery>(
                x => x.Statement == "MATCH (tom:Person {name: \"Tom Hanks\"})-[:ACTED_IN]->(tomHanksMovies) WHERE tomHanksMovies.released>2000 RETURN tomHanksMovies.title, tomHanksMovies.released"
                );
            var factory   = new BoltCommandFactory();
            var cmd       = factory.Instantiate(conn, query).Implementation;
            var statement = cmd as Driver.Statement;

            var session = conn.CreateSession();
            var results = session.Run(statement);

            Assert.That(results.Count, Is.EqualTo(4));
            Assert.That(results.Keys.Count(), Is.EqualTo(2));
        }
        //[Ignore("Neo4j extension doesn't support non-string parameters at the moment.")]
        public void Instantiate_OneParameterWithTypeInt_CorrectResultSet()
        {
            var conn          = new BoltClient("127.0.0.1", "7687", "neo4j", "bolt");
            var paramReleased = new QueryParameter("movieReleased", "Integer", new LiteralScalarResolver <object>(new LiteralScalarResolverArgs("2000")));

            var query = Mock.Of <IQuery>(
                x => x.Statement == "MATCH (tom:Person {name: \"Tom Hanks\"})-[:ACTED_IN]->(tomHanksMovies) WHERE tomHanksMovies.released>$movieReleased RETURN tomHanksMovies.title, tomHanksMovies.released" &&
                x.Parameters == new List <IQueryParameter>()
            {
                paramReleased
            }
                );
            var factory   = new BoltCommandFactory();
            var cmd       = factory.Instantiate(conn, query).Implementation;
            var statement = cmd as Driver.Statement;

            var session = conn.CreateSession();
            var results = session.Run(statement);

            Assert.That(results.Count, Is.EqualTo(4));
            Assert.That(results.Keys.Count(), Is.EqualTo(2));
        }