当前位置: 首页>>代码示例>>C#>>正文


C# RestTestHarness.CreateAndConnectGraphClient方法代码示例

本文整理汇总了C#中RestTestHarness.CreateAndConnectGraphClient方法的典型用法代码示例。如果您正苦于以下问题:C# RestTestHarness.CreateAndConnectGraphClient方法的具体用法?C# RestTestHarness.CreateAndConnectGraphClient怎么用?C# RestTestHarness.CreateAndConnectGraphClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RestTestHarness的用法示例。


在下文中一共展示了RestTestHarness.CreateAndConnectGraphClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldReturnNodeData

        public void ShouldReturnNodeData()
        {
            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.Get("/node/456"),
                    MockResponse.Json(HttpStatusCode.OK,
                        @"{ 'self': 'http://foo/db/data/node/456',
                          'data': { 'Foo': 'foo',
                                    'Bar': 'bar',
                                    'Baz': 'baz'
                          },
                          'create_relationship': 'http://foo/db/data/node/456/relationships',
                          'all_relationships': 'http://foo/db/data/node/456/relationships/all',
                          'all_typed relationships': 'http://foo/db/data/node/456/relationships/all/{-list|&|types}',
                          'incoming_relationships': 'http://foo/db/data/node/456/relationships/in',
                          'incoming_typed relationships': 'http://foo/db/data/node/456/relationships/in/{-list|&|types}',
                          'outgoing_relationships': 'http://foo/db/data/node/456/relationships/out',
                          'outgoing_typed relationships': 'http://foo/db/data/node/456/relationships/out/{-list|&|types}',
                          'properties': 'http://foo/db/data/node/456/properties',
                          'property': 'http://foo/db/data/node/456/property/{key}',
                          'traverse': 'http://foo/db/data/node/456/traverse/{returnType}'
                        }")
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();
                var node = graphClient.Get<TestNode>((NodeReference)456);

                Assert.AreEqual(456, node.Reference.Id);
                Assert.AreEqual("foo", node.Data.Foo);
                Assert.AreEqual("bar", node.Data.Bar);
                Assert.AreEqual("baz", node.Data.Baz);
            }
        }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:35,代码来源:GetNodeTests.cs

示例2: ShouldCreateIndex

        public void ShouldCreateIndex(
            IndexFor indexFor,
            IndexProvider indexProvider,
            IndexType indexType,
            string createEndpoint,
            string createJson)
        {
            //Arrange
            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostJson(createEndpoint, createJson),
                    MockResponse.Http(201)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                var indexConfiguration = new IndexConfiguration
                {
                    Provider = indexProvider,
                    Type = indexType
                };
                graphClient.CreateIndex("foo", indexConfiguration, indexFor);
            }
        }
开发者ID:albumprinter,项目名称:Neo4jClient,代码行数:26,代码来源:CreateIndexTests.cs

示例3: ShouldReturnEmptyEnumerableForNullResult

        public void ShouldReturnEmptyEnumerableForNullResult()
        {
            //Arrange
            const string gremlinQueryExpected = "foo bar query";
            var query = new GremlinApiQuery(gremlinQueryExpected, null);

            using (var testHarness = new RestTestHarness
                {
                    {
                        MockRequest.PostObjectAsJson("/ext/GremlinPlugin/graphdb/execute_script", query),
                        MockResponse.Json(HttpStatusCode.OK, @"[]")
                    }
                })
            {
                var graphClient = (GraphClient)testHarness.CreateAndConnectGraphClient();

                //Act
                var nodes = graphClient
                    .ExecuteGetAllRelationshipsGremlin(gremlinQueryExpected, null)
                    .ToList();

                //Assert
                Assert.AreEqual(0, nodes.Count());
            }
        }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:25,代码来源:ExecuteGetAllRelationshipsGremlinTests.cs

示例4: ShouldUpdatePayload

        public void ShouldUpdatePayload()
        {
            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.Get("/relationship/456/properties"),
                    MockResponse.Json(HttpStatusCode.OK, "{ 'Foo': 'foo', 'Bar': 'bar', 'Baz': 'baz' }")
                },
                {
                    MockRequest.PutObjectAsJson(
                        "/relationship/456/properties",
                        new TestPayload { Foo = "fooUpdated", Bar = "bar", Baz = "bazUpdated" }),
                    MockResponse.Http((int)HttpStatusCode.NoContent)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                graphClient.Update(
                    new RelationshipReference<TestPayload>(456),
                    payloadFromDb =>
                        {
                            payloadFromDb.Foo = "fooUpdated";
                            payloadFromDb.Baz = "bazUpdated";
                        }
                    );
            }
        }
开发者ID:albumprinter,项目名称:Neo4jClient,代码行数:28,代码来源:UpdateRelationshipTests.cs

示例5: ShouldSendCommandAndNotCareAboutResults

        public void ShouldSendCommandAndNotCareAboutResults()
        {
            // Arrange
            const string queryText = @"START d=node({p0}), e=node({p1}) CREATE UNIQUE d-[:foo]->e";
            var parameters = new Dictionary<string, object>
            {
                {"p0", 215},
                {"p1", 219}
            };

            var cypherQuery = new CypherQuery(queryText, parameters, CypherResultMode.Set);
            var cypherApiQuery = new CypherApiQuery(cypherQuery);

            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostObjectAsJson("/cypher", cypherApiQuery),
                    MockResponse.Http((int)HttpStatusCode.OK)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                //Act
                graphClient.ExecuteCypher(cypherQuery);
            }
        }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:27,代码来源:ExecuteCypherTests.cs

示例6: ShouldSendCommandAndNotCareAboutResultsAsync

        public void ShouldSendCommandAndNotCareAboutResultsAsync()
        {
            // Arrange
            const string queryText = @"return 1";
            var parameters = new Dictionary<string, object>();

            var cypherQuery = new CypherQuery(queryText, parameters, CypherResultMode.Set);
            var cypherApiQuery = new CypherApiQuery(cypherQuery);

            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostObjectAsJson("/cypher", cypherApiQuery),
                    MockResponse.Http((int)HttpStatusCode.OK)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                bool raisedEvent = false;

                graphClient.OperationCompleted += (sender, e) => { raisedEvent = true; };

                //Act
                var task = graphClient.ExecuteCypherAsync(cypherQuery);
                task.Wait();

                Assert.IsTrue(raisedEvent, "Raised OperationCompleted");
            }
        }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:30,代码来源:ExecuteCypherTests.cs

示例7: ShouldDeserializePathsResultAsSetBased

        [Test] public void ShouldDeserializePathsResultAsSetBased()
        {
            // Arrange
            const string queryText = @"START d=node({p0}), e=node({p1})
                                        MATCH p = allShortestPaths( d-[*..15]-e )
                                        RETURN p";

            var parameters = new Dictionary<string, object>
                {
                    {"p0", 215},
                    {"p1", 219}
                };

            var cypherQuery = new CypherQuery(queryText, parameters, CypherResultMode.Set, CypherResultFormat.Rest);
            var cypherApiQuery = new CypherApiQuery(cypherQuery);

            using (var testHarness = new RestTestHarness
                {
                    {
                    MockRequest.PostObjectAsJson("/cypher", cypherApiQuery),
                    MockResponse.Json(HttpStatusCode.OK,
                    @"{
                              'data' : [ [ {
                                'start' : 'http://foo/db/data/node/215',
                                'nodes' : [ 'http://foo/db/data/node/215', 'http://foo/db/data/node/0', 'http://foo/db/data/node/219' ],
                                'length' : 2,
                                'relationships' : [ 'http://foo/db/data/relationship/247', 'http://foo/db/data/relationship/257' ],
                                'end' : 'http://foo/db/data/node/219'
                              } ], [ {
                                'start' : 'http://foo/db/data/node/215',
                                'nodes' : [ 'http://foo/db/data/node/215', 'http://foo/db/data/node/1', 'http://foo/db/data/node/219' ],
                                'length' : 2,
                                'relationships' : [ 'http://foo/db/data/relationship/248', 'http://foo/db/data/relationship/258' ],
                                'end' : 'http://foo/db/data/node/219'
                              } ] ],
                              'columns' : [ 'p' ]
                            }")
                    }
                })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                //Act
                var results = graphClient
                    .ExecuteGetCypherResults<PathsResult>(cypherQuery)
                    .ToArray();

                //Assert
                Assert.IsInstanceOf<IEnumerable<PathsResult>>(results);
                Assert.AreEqual(results.First().Length, 2);
                Assert.AreEqual(results.First().Start, "http://foo/db/data/node/215");
                Assert.AreEqual(results.First().End, "http://foo/db/data/node/219");
                Assert.AreEqual(results.Skip(1).First().Length, 2);
                Assert.AreEqual(results.Skip(1).First().Start, "http://foo/db/data/node/215");
                Assert.AreEqual(results.Skip(1).First().End, "http://foo/db/data/node/219");
            }
        }
开发者ID:KodrAus,项目名称:Neo4jClient,代码行数:57,代码来源:ExecuteGetCypherResultsTests.cs

示例8: RootNodeShouldHaveReferenceBackToClient

 public void RootNodeShouldHaveReferenceBackToClient()
 {
     using (var testHarness = new RestTestHarness())
     {
         var client = testHarness.CreateAndConnectGraphClient();
         var rootNode = client.RootNode;
         Assert.AreEqual(client, ((IGremlinQuery) rootNode).Client);
     }
 }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:9,代码来源:RootNodeTests.cs

示例9: RootNode_ShouldReturnReferenceNode

        public void RootNode_ShouldReturnReferenceNode()
        {
            using (var testHarness = new RestTestHarness())
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                Assert.IsNotNull(graphClient.RootNode);
                Assert.AreEqual(123, graphClient.RootNode.Id);
            }
        }
开发者ID:neildobson71,项目名称:Neo4jClient,代码行数:10,代码来源:ConnectTests.cs

示例10: RootNodeShouldSupportGremlinQueries

 public void RootNodeShouldSupportGremlinQueries()
 {
     using (var testHarness = new RestTestHarness())
     {
         var client = testHarness.CreateAndConnectGraphClient();
         var rootNode = client.RootNode;
         Assert.AreEqual("g.v(p0)", ((IGremlinQuery) rootNode).QueryText);
         Assert.AreEqual(123, ((IGremlinQuery) rootNode).QueryParameters["p0"]);
     }
 }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:10,代码来源:RootNodeTests.cs

示例11: ShouldRetrieveApiEndpoints

 public void ShouldRetrieveApiEndpoints()
 {
     using (var testHarness = new RestTestHarness())
     {
         var graphClient = (GraphClient)testHarness.CreateAndConnectGraphClient();
         Assert.AreEqual("/node", graphClient.RootApiResponse.Node);
         Assert.AreEqual("/index/node", graphClient.RootApiResponse.NodeIndex);
         Assert.AreEqual("/index/relationship", graphClient.RootApiResponse.RelationshipIndex);
         Assert.AreEqual("http://foo/db/data/node/123", graphClient.RootApiResponse.ReferenceNode);
         Assert.AreEqual("/ext", graphClient.RootApiResponse.ExtensionsInfo);
     }
 }
开发者ID:albumprinter,项目名称:Neo4jClient,代码行数:12,代码来源:ConnectTests.cs

示例12: ShouldParse15M02Version

        public void ShouldParse15M02Version()
        {
            using (var testHarness = new RestTestHarness
            {
                { MockRequest.Get(""), MockResponse.NeoRoot() }
            })
            {
                var graphClient = (GraphClient)testHarness.CreateAndConnectGraphClient();

                Assert.AreEqual("1.5.0.2", graphClient.ServerVersion.ToString());
            }
        }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:12,代码来源:ServerVersionTests.cs

示例13: ShouldThrowConnectionExceptionFor500Response

 public void ShouldThrowConnectionExceptionFor500Response()
 {
     using (var testHarness = new RestTestHarness
     {
         {
             MockRequest.Get(""),
             MockResponse.Http(500)
         }
     })
     {
         testHarness.CreateAndConnectGraphClient();
     }
 }
开发者ID:KodrAus,项目名称:Neo4jClient,代码行数:13,代码来源:ConnectTests.cs

示例14: ShouldDeleteRelationship

 public void ShouldDeleteRelationship()
 {
     using (var testHarness = new RestTestHarness
     {
         {
             MockRequest.Delete("/relationship/456"),
             MockResponse.Http(204)
         }
     })
     {
         var graphClient = testHarness.CreateAndConnectGraphClient();
         graphClient.DeleteRelationship(456);
     }
 }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:14,代码来源:DeleteRelationshipTests.cs

示例15: ShouldDeleteNodeOnly

 public void ShouldDeleteNodeOnly()
 {
     using (var testHarness = new RestTestHarness
     {
         {
             MockRequest.Delete("/node/456"),
             MockResponse.Http(204)
         }
     })
     {
         var graphClient = testHarness.CreateAndConnectGraphClient();
         graphClient.Delete(456, DeleteMode.NodeOnly);
     }
 }
开发者ID:Winsto,项目名称:Neo4jClient,代码行数:14,代码来源:DeleteNodeTests.cs


注:本文中的RestTestHarness.CreateAndConnectGraphClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。