コード例 #1
0
        public static MockRequest PostObjectAsJson(string uri, object body)
        {
            var test = new MockRequest
            {
                Resource = uri,
                Method   = HttpMethod.Post,
                Body     = new CustomJsonSerializer {
                    JsonConverters = GraphClient.DefaultJsonConverters
                }.Serialize(body)
            };

            return(new MockRequest
            {
                Resource = uri,
                Method = HttpMethod.Post,
                Body = new CustomJsonSerializer {
                    JsonConverters = GraphClient.DefaultJsonConverters
                }.Serialize(body)
            });
        }
コード例 #2
0
                public async Task ReturnsQueryStats_WhenInTransaction()
                {
                    var          response = MockResponse.Json(201, @"{
    'results': [
        {
            'columns': [
                'id(n)'
            ],
            'data': [
                {
                    'row': [
                        4
                    ],
                    'meta': [
                        null
                    ]
                }
            ],
            'stats': {
                'contains_updates': false,
                'nodes_created': 0,
                'nodes_deleted': 0,
                'properties_set': 0,
                'relationships_created': 0,
                'relationship_deleted': 0,
                'labels_added': 0,
                'labels_removed': 0,
                'indexes_added': 0,
                'indexes_removed': 0,
                'constraints_added': 0,
                'constraints_removed': 0,
                'contains_system_updates': false,
                'system_updates': 0
            }
        }
    ],
    'errors': [],
    'commit': 'http://*****:*****@"{
  'statements': [
    {
      'statement': 'MATCH (n)\r\nRETURN id(n)',
      'resultDataContents': [],
      'parameters': {},
      'includeStats': true
    }
  ]
}");
                    var          rollbackTransactionRequest = MockRequest.Delete($"/db/{database}/tx/1");

                    using (var testHarness = new RestTestHarness(false, "http://*****:*****@"{'results':[], 'errors':[] }") }
                    })
                    {
                        var graphClient = await testHarness.CreateAndConnectTransactionalGraphClient(RestTestHarness.Neo4jVersion.Neo40);

                        var        completedRaised = false;
                        QueryStats stats           = null;
                        graphClient.OperationCompleted += (o, e) =>
                        {
                            stats           = e.QueryStats;
                            completedRaised = true;
                        };

                        using (var tx = graphClient.BeginTransaction())
                        {
                            var query = graphClient.Cypher.WithQueryStats.Match("(n)").Return(n => n.Id());
                            query.Query.IncludeQueryStats.Should().BeTrue();

                            await query.ExecuteWithoutResultsAsync();

                            completedRaised.Should().BeTrue();
                            stats.Should().NotBeNull();
                        }
                    }
                }
コード例 #3
0
 public void Add(MockRequest request, MockResponse response)
 {
     recordedResponses.Add(request, response);
 }