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/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 a45d81d72..dca53940a 100644 --- a/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/SupportedFeatures.cs +++ b/Neo4j.Driver/Neo4j.Driver.Tests.TestBackend/SupportedFeatures.cs @@ -13,9 +13,9 @@ internal static class SupportedFeatures static SupportedFeatures() { FeaturesList.Add("AuthorizationExpiredTreatment"); - + FeaturesList.Add("ConfHint:connection.recv_timeout_seconds"); - + FeaturesList.Add("Optimization:EagerTransactionBegin"); FeaturesList.Add("Feature:Auth:Bearer"); @@ -34,7 +34,7 @@ static SupportedFeatures() //FeaturesList.Add("Feature:API:SSLSchemes"); //FeaturesList.Add("Feature:API:Result.Single"); - //FeaturesList.Add("Feature:API:Result.Peek"); + FeaturesList.Add("Feature:API:Result.Peek"); //FeaturesList.Add("Feature:API:Result.List");