diff --git a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Protocol.cs b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Protocol.cs index ad1db5590..5f8fd9181 100644 --- a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Protocol.cs +++ b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Protocol.cs @@ -41,6 +41,7 @@ public static class Protocol typeof(SessionBeginTransaction), typeof(Result), typeof(ResultNext), + typeof(ResultPeek), typeof(ResultConsume), typeof(RetryablePositive), typeof(RetryableNegative), @@ -69,7 +70,7 @@ public static void ValidateType(string typeName) catch { throw new TestKitProtocolException($"Attempting to use an unrecognized protocol type: {typeName}"); - } + } } public static void ValidateType(Type objectType) diff --git a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/Result.cs b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/Result.cs index 1f19d66c2..a716011c9 100644 --- a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/Result.cs +++ b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/Result.cs @@ -41,6 +41,11 @@ public async Task GetNextRecord() return await Task.FromResult(null); } + public Task PeekRecord() + { + return ResultCursor.PeekAsync(); + } + public async Task ConsumeResults() { return await ResultCursor.ConsumeAsync().ConfigureAwait(false); diff --git a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/ResultNext.cs b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/ResultNext.cs index d28316bb4..6ed9c8132 100644 --- a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/ResultNext.cs +++ b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/ResultNext.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Diagnostics; - namespace Neo4j.Driver.Tests.TestBackend { internal class ResultNext : IProtocolObject @@ -19,23 +18,23 @@ public class ResultNextType public string resultId { get; set; } } - public override async Task Process() - { - var result = (Result)ObjManager.GetObject(data.resultId); - Records = await result.GetNextRecord(); + public override async Task Process() + { + var result = (Result)ObjManager.GetObject(data.resultId); + Records = await result.GetNextRecord(); } public override string Respond() { if (!(Records is null)) { - //Generate list of ordered records - var valuesList = Records.Keys.Select(v => NativeToCypher.Convert(Records[v])); + //Generate list of ordered records + var valuesList = Records.Keys.Select(v => NativeToCypher.Convert(Records[v])); return new ProtocolResponse("Record", new { values = valuesList }).Encode(); } else { - return new ProtocolResponse("NullRecord", (object)null).Encode(); + return new ProtocolResponse("NullRecord", (object)null).Encode(); } } } diff --git a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/ResultPeek.cs b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/ResultPeek.cs new file mode 100644 index 000000000..1ff91e908 --- /dev/null +++ b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/Protocol/Result/ResultPeek.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; +using System.Threading.Tasks; +using System.Linq; + +namespace Neo4j.Driver.Tests.TestBackend +{ + internal class ResultPeek : IProtocolObject + { + public ResultPeekType data { get; set; } = new ResultPeekType(); + + public IRecord Records { get; set; } + + public class ResultPeekType + { + public string resultId { get; set; } + } + + public override async Task Process() + { + var result = (Result)ObjManager.GetObject(data.resultId); + Records = await result.PeekRecord(); + } + + public override string Respond() + { + if (Records is null) + return new ProtocolResponse("NullRecord", (object)null).Encode(); + + //Generate list of ordered records + var valuesList = Records.Keys.Select(v => NativeToCypher.Convert(Records[v])); + return new ProtocolResponse("Record", new { values = valuesList }).Encode(); + } + } +} diff --git a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/SupportedFeatures.cs b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/SupportedFeatures.cs index 0875119e7..751aabaf9 100644 --- a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/SupportedFeatures.cs +++ b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/SupportedFeatures.cs @@ -11,7 +11,7 @@ static SupportedFeatures() FeaturesList = new List { //"Feature:API:Result.List", - //"Feature:API:Result.Peek", + "Feature:API:Result.Peek", //"Feature:API:Result.Single", //"Feature:API:Liveness.Check", //"Feature:API:SSLConfig",