本文整理汇总了C#中RestTestHarness.CreateGraphClient方法的典型用法代码示例。如果您正苦于以下问题:C# RestTestHarness.CreateGraphClient方法的具体用法?C# RestTestHarness.CreateGraphClient怎么用?C# RestTestHarness.CreateGraphClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestTestHarness
的用法示例。
在下文中一共展示了RestTestHarness.CreateGraphClient方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnsCorrectError_WhenTransactionIsAutomaticallyRolledBack_ViaNeo4j_2_2_6_Plus
//https://github.com/Readify/Neo4jClient/issues/127
public void ReturnsCorrectError_WhenTransactionIsAutomaticallyRolledBack_ViaNeo4j_2_2_6_Plus([Values(RestTestHarness.Neo4jVersion.Neo226/*, RestTestHarness.Neo4jVersion.Neo23*/)] RestTestHarness.Neo4jVersion version)
{
/* In 2.2.6 ClientErrors (Constraint Violations etc) were changed to Automatically rollback. This created a 404 error when *we* tried to rollback on an error, as the transaction no longer existed. */
var initTransactionRequest = MockRequest.PostJson("/transaction", @"{
'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");
using (var testHarness = new RestTestHarness
{
{
initTransactionRequest,
MockResponse.Json(201, TransactionRestResponseHelper.GenerateCypherErrorResponse(1, "{\"code\":\"Neo.ClientError.Schema.ConstraintViolation\",\"message\":\"Node 19572 already exists with label User and property.\"}"), "http://foo/db/data/transaction/1")
},
{
rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
}
})
{
var client = testHarness.CreateGraphClient(version);
client.Connect();
using (var transaction = client.BeginTransaction())
{
client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResults();
}
}
}
示例2: ReturnsThe404_WhenVersionIs_2_2_6_Plus_WhenActuallyTimingOut
//https://github.com/Readify/Neo4jClient/issues/127
public void ReturnsThe404_WhenVersionIs_2_2_6_Plus_WhenActuallyTimingOut([Values(RestTestHarness.Neo4jVersion.Neo226, RestTestHarness.Neo4jVersion.Neo23)] RestTestHarness.Neo4jVersion version)
{
var initTransactionRequest = MockRequest.PostJson("/transaction", @"{
'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");
using (var testHarness = new RestTestHarness()
{
{
initTransactionRequest,
MockResponse.Json(201, TransactionRestResponseHelper.GenerateInitTransactionResponse(1), "http://foo/db/data/transaction/1")
},
{
rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
}
})
{
var client = testHarness.CreateGraphClient(version);
client.Connect();
try
{
using (var transaction = client.BeginTransaction())
{
client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResults();
}
Assert.Fail("Should not reach this code, as there is an expected exception.");
}
catch (ApplicationException ex)
{
Assert.That(ex.Message.Contains("404"));
}
}
}
示例3: BeginTransactionShouldFailWithLower20Versions
public void BeginTransactionShouldFailWithLower20Versions()
{
using (var testHarness = new RestTestHarness())
{
var client = testHarness.CreateGraphClient(false);
client.Connect();
client.BeginTransaction();
}
}
示例4: BeginTransactionShouldFailWithLower20Versions
public void BeginTransactionShouldFailWithLower20Versions()
{
using (var testHarness = new RestTestHarness())
{
var client = testHarness.CreateGraphClient(RestTestHarness.Neo4jVersion.Neo19);
client.Connect();
Assert.That(() => client.BeginTransaction(), Throws.TypeOf<NotSupportedException>());
}
}
示例5: ReturnsThe404_WhenVersionIsLessThan_2_2_6
//https://github.com/Readify/Neo4jClient/issues/127
public void ReturnsThe404_WhenVersionIsLessThan_2_2_6([Values(RestTestHarness.Neo4jVersion.Neo20, RestTestHarness.Neo4jVersion.Neo22, RestTestHarness.Neo4jVersion.Neo225)] RestTestHarness.Neo4jVersion version)
{
var initTransactionRequest = MockRequest.PostJson("/transaction", @"{
'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");
using (var testHarness = new RestTestHarness
{
{
initTransactionRequest,
MockResponse.Json(201, TransactionRestResponseHelper.GenerateCypherErrorResponse(1, "{\"code\":\"Neo.ClientError.Schema.ConstraintViolation\",\"message\":\"Node 19572 already exists with label User and property.\"}"), "http://foo/db/data/transaction/1")
},
{
rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
}
})
{
var client = testHarness.CreateGraphClient(version);
client.Connect();
try
{
using (var transaction = client.BeginTransaction())
{
client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResults();
}
}
catch (ApplicationException ex)
{
Assert.That(ex.Message.Contains("404"));
}
}
}