8
8
using Neo4j . Driver ;
9
9
using Neo4jClient . ApiModels . Cypher ;
10
10
using Neo4jClient . Cypher ;
11
+ using Newtonsoft . Json . Serialization ;
11
12
using Xunit ;
12
13
13
14
namespace Neo4jClient . Tests . BoltGraphClientTests . Cypher
@@ -89,7 +90,7 @@ public bool Equals(INode other)
89
90
90
91
#region Implementation of INode
91
92
92
- public IReadOnlyList < string > Labels { get ; }
93
+ public IReadOnlyList < string > Labels { get ; set ; }
93
94
94
95
#endregion
95
96
}
@@ -718,5 +719,59 @@ public async Task ShouldDeserializePathsResultAsSetBased()
718
719
results . First ( ) . Start . Id . Should ( ) . Be ( 2 ) ;
719
720
}
720
721
}
722
+
723
+ [ Fact ]
724
+ public async Task ShouldDeserializePathsResultWhenUsingCamelCaseResolver ( )
725
+ {
726
+ // Arrange
727
+ const string queryText = @"MATCH (start:Node {Id:$p0}),(end:Node {Id: $p1}), p = shortestPath((start)-[*..5]->(end)) RETURN p" ;
728
+
729
+ var parameters = new Dictionary < string , object >
730
+ {
731
+ { "p0" , 215 } ,
732
+ { "p1" , 219 }
733
+ } ;
734
+
735
+ var cypherQuery = new CypherQuery ( queryText , parameters , CypherResultMode . Set , CypherResultFormat . Rest , "neo4j" ) ;
736
+
737
+ using ( var testHarness = new BoltTestHarness ( ) )
738
+ {
739
+ var recordMock = new Mock < IRecord > ( ) ;
740
+ recordMock
741
+ . Setup ( r => r [ "p" ] )
742
+ . Returns ( new TestPath
743
+ {
744
+ End = new TestNode { Id = 1 , Labels = new [ ] { "Node" } } ,
745
+ Start = new TestNode { Id = 2 , Labels = new [ ] { "Node" } } ,
746
+ Relationships = new List < IRelationship > { new TestRelationship { Id = 3 , StartNodeId = 2 , EndNodeId = 1 , Type = "Foo" } } ,
747
+ Nodes = new List < INode > { new TestNode ( ) , new TestNode ( ) }
748
+ } ) ;
749
+ recordMock
750
+ . Setup ( r => r . Keys )
751
+ . Returns ( new [ ] { "p" } ) ;
752
+
753
+ var testStatementResult = new TestStatementResult ( new [ ] { "p" } , recordMock . Object ) ;
754
+ testHarness . SetupCypherRequestResponse ( cypherQuery . QueryText , cypherQuery . QueryParameters , testStatementResult ) ;
755
+
756
+ var graphClient = await testHarness . CreateAndConnectBoltGraphClient ( ) ;
757
+ graphClient . JsonContractResolver = new CamelCasePropertyNamesContractResolver ( ) ;
758
+ var results = ( await graphClient . ExecuteGetCypherResultsAsync < PathsResultBolt > ( cypherQuery ) ) . ToArray ( ) ;
759
+
760
+ //Assert
761
+ Assert . IsAssignableFrom < IEnumerable < PathsResultBolt > > ( results ) ;
762
+ var resultPath = results . First ( ) ;
763
+ Assert . Equal ( 1 , resultPath . Length ) ;
764
+ resultPath . Nodes . Count . Should ( ) . Be ( 2 ) ;
765
+ resultPath . End . Id . Should ( ) . Be ( 1 ) ;
766
+ resultPath . End . Labels . Should ( ) . BeEquivalentTo ( "Node" ) ;
767
+ resultPath . Start . Id . Should ( ) . Be ( 2 ) ;
768
+ resultPath . Start . Labels . Should ( ) . BeEquivalentTo ( "Node" ) ;
769
+ resultPath . Relationships . Count . Should ( ) . Be ( 1 ) ;
770
+ resultPath . Relationships [ 0 ] . Id . Should ( ) . Be ( 3 ) ;
771
+ resultPath . Relationships [ 0 ] . StartNodeId . Should ( ) . Be ( 2 ) ;
772
+ resultPath . Relationships [ 0 ] . EndNodeId . Should ( ) . Be ( 1 ) ;
773
+ resultPath . Relationships [ 0 ] . Type . Should ( ) . Be ( "Foo" ) ;
774
+ }
775
+ }
721
776
}
722
777
}
0 commit comments