Пример #1
0
        public void CreateAFullPath()
        {
            //http://docs.neo4j.org/chunked/milestone/query-create.html#create-create-a-full-path
            // START n=node(1)
            // CREATE n-[r:REL]->(a {Foo: 'foo', Bar: 'bar', Baz: 'baz'})-[r:REL]->(b {Foo: 'foo2', Bar: 'bar2', Baz: 'baz2'})
            // RETURN a

            var data1 = new CreateNodeTests.TestNode {
                Foo = "foo", Bar = "bar", Baz = "baz"
            };
            var data2 = new CreateNodeTests.TestNode {
                Foo = "foo2", Bar = "bar2", Baz = "baz2"
            };
            var client = Substitute.For <IRawGraphClient>();
            var query  = new CypherFluentQuery(client)
                         .Match("n")
                         .Create("n-[r:REL]->(a $p0)-[r:REL]->(b $p1)")
                         .WithParams(new { p0 = data1, p1 = data2 })
                         .Return <CreateNodeTests.TestNode>("a")
                         .Query;

            Assert.Equal("MATCH n" + Environment.NewLine + "CREATE n-[r:REL]->(a $p0)-[r:REL]->(b $p1)" + Environment.NewLine + "RETURN a", query.QueryText);
            Assert.Equal(data1, query.QueryParameters["p0"]);
            Assert.Equal(data2, query.QueryParameters["p1"]);
        }
Пример #2
0
        public void CreateNode()
        {
            //http://docs.neo4j.org/chunked/milestone/query-create.html#create-create-single-node-and-set-properties
            // CREATE (a {Foo: 'foo', Bar: 'bar', Baz: 'baz'})
            // RETURN a

            var data = new CreateNodeTests.TestNode {
                Foo = "foo", Bar = "bar", Baz = "baz"
            };
            var client = Substitute.For <IRawGraphClient>();
            var query  = new CypherFluentQuery(client)
                         .Create("a", data)
                         .Return <object>("a")
                         .Query;

            Assert.AreEqual("CREATE (a {p0})\r\nRETURN a", query.QueryText);
            Assert.AreEqual(data, query.QueryParameters["p0"]);
        }
Пример #3
0
        public void CreateAFullPath()
        {
            //http://docs.neo4j.org/chunked/milestone/query-create.html#create-create-a-full-path
            // START n=node(1)
            // CREATE n-[r:REL]->(a {Foo: 'foo', Bar: 'bar', Baz: 'baz'})-[r:REL]->(b {Foo: 'foo2', Bar: 'bar2', Baz: 'baz2'})
            // RETURN a

            var data1 = new CreateNodeTests.TestNode { Foo = "foo", Bar = "bar", Baz = "baz" };
            var data2 = new CreateNodeTests.TestNode { Foo = "foo2", Bar = "bar2", Baz = "baz2" };
            var client = Substitute.For<IRawGraphClient>();
            var query = new CypherFluentQuery(client)
                .Start("n", (NodeReference)1)
                .Create("n-[r:REL]->(a {0})-[r:REL]->(b {1})", data1, data2)
                .Return<CreateNodeTests.TestNode>("a")
                .Query;
            Assert.AreEqual("START n=node({p0})\r\nCREATE n-[r:REL]->(a {p1})-[r:REL]->(b {p2})\r\nRETURN a", query.QueryText);
            Assert.AreEqual(data1, query.QueryParameters["p1"]);
            Assert.AreEqual(data2, query.QueryParameters["p2"]);
        }
Пример #4
0
        public void CreateAFullPath()
        {
            //http://docs.neo4j.org/chunked/milestone/query-create.html#create-create-a-full-path
            // START n=node(1)
            // CREATE n-[r:REL]->(a {Foo: 'foo', Bar: 'bar', Baz: 'baz'})-[r:REL]->(b {Foo: 'foo2', Bar: 'bar2', Baz: 'baz2'})
            // RETURN a

            var data1 = new CreateNodeTests.TestNode {
                Foo = "foo", Bar = "bar", Baz = "baz"
            };
            var data2 = new CreateNodeTests.TestNode {
                Foo = "foo2", Bar = "bar2", Baz = "baz2"
            };
            var client = Substitute.For <IRawGraphClient>();
            var query  = new CypherFluentQuery(client)
                         .Start("n", (NodeReference)1)
                         .Create("n-[r:REL]->(a {0})-[r:REL]->(b {1})", data1, data2)
                         .Return <CreateNodeTests.TestNode>("a")
                         .Query;

            Assert.AreEqual("START n=node({p0})\r\nCREATE n-[r:REL]->(a {p1})-[r:REL]->(b {p2})\r\nRETURN a", query.QueryText);
            Assert.AreEqual(data1, query.QueryParameters["p1"]);
            Assert.AreEqual(data2, query.QueryParameters["p2"]);
        }
Пример #5
0
        public void CreateNode()
        {
            //http://docs.neo4j.org/chunked/milestone/query-create.html#create-create-single-node-and-set-properties
            // CREATE (a {Foo: 'foo', Bar: 'bar', Baz: 'baz'})
            // RETURN a

            var data = new CreateNodeTests.TestNode {Foo = "foo", Bar = "bar", Baz = "baz"};
            var client = Substitute.For<IRawGraphClient>();
            var query = new CypherFluentQuery(client)
                .Create("a", data)
                .Return<object>("a")
                .Query;
            Assert.AreEqual("CREATE (a {p0})\r\nRETURN a", query.QueryText);
            Assert.AreEqual(data, query.QueryParameters["p0"]);
        }