Skip to content
This repository
Browse code

Update to support BATCH processing.

Added neo4jRestNet config section to app.cofig file.

refactored may methods in INode and IRelationship.

refactored Node/Relationship to be instance objects - breaking change for older versions

moved Cypher out of Plugin namespace since it is now core to Neo4j
  • Loading branch information...
commit fe56e9196c994a9b82d65c0828379afca6277591 1 parent dfeeed3
Michael authored

Showing 45 changed files with 4,470 additions and 1,205 deletions. Show diff stats Hide diff stats

  1. +19 6 Neo4jRestNet.Test/App.config
  2. +791 0 Neo4jRestNet.Test/BatchStoreTest.cs
  3. +15 21 Neo4jRestNet.Test/EncryptedIDTest.cs
  4. +7 1 Neo4jRestNet.Test/Neo4jRestNet.Test.csproj
  5. +822 0 Neo4jRestNet.Test/NodeClassTest.cs
  6. +0 12 Neo4jRestNet.sln
  7. +19 0 Neo4jRestNet/Configuration/ConnectionCollection.cs
  8. +81 0 Neo4jRestNet/Configuration/ConnectionElement.cs
  9. +23 0 Neo4jRestNet/Configuration/ConnectionManager.cs
  10. +14 0 Neo4jRestNet/Configuration/ConnectionSettings.cs
  11. +121 0 Neo4jRestNet/Core/BatchNodeStore.cs
  12. +122 0 Neo4jRestNet/Core/BatchRelationshipStore.cs
  13. +716 0 Neo4jRestNet/Core/BatchStore.cs
  14. +14 0 Neo4jRestNet/Core/Exceptions/BatchDeleteNotSupported.cs
  15. +14 0 Neo4jRestNet/Core/Exceptions/BatchGetRelationshipsNotSupported.cs
  16. +14 0 Neo4jRestNet/Core/Exceptions/BatchRemoveFromIndexNotSupported.cs
  17. +14 0 Neo4jRestNet/Core/Exceptions/NodeNotFound.cs
  18. +2 0  Neo4jRestNet/Core/IGraphObject.cs
  19. +35 0 Neo4jRestNet/Core/INodeStore.cs
  20. +35 0 Neo4jRestNet/Core/IRelationshipStore.cs
  21. +256 453 Neo4jRestNet/Core/Node.cs
  22. +57 20 Neo4jRestNet/Core/Path.cs
  23. +11 0 Neo4jRestNet/Core/Properties.cs
  24. +201 287 Neo4jRestNet/Core/Relationship.cs
  25. +421 0 Neo4jRestNet/Core/RestNodeStore.cs
  26. +449 0 Neo4jRestNet/Core/RestRelationshipStore.cs
  27. +8 12 Neo4jRestNet/{CypherPlugin → Cypher}/Cypher.cs
  28. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/CypherMatch.cs
  29. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/CypherOrderBy.cs
  30. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/CypherProperty.cs
  31. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/CypherReturn.cs
  32. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/CypherStart.cs
  33. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/CypherWhere.cs
  34. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/ICypherObject.cs
  35. +1 1  Neo4jRestNet/{CypherPlugin → Cypher}/ParseWhereLambda.cs
  36. +12 17 Neo4jRestNet/GremlinPlugin/Gremlin.cs
  37. +2 2 Neo4jRestNet/GremlinPlugin/JavaStringCommands.cs
  38. +26 10 Neo4jRestNet/Neo4jRestNet.csproj
  39. +7 5 Neo4jRestNet/Properties/AssemblyInfo.cs
  40. +57 18 Neo4jRestNet/Rest/HttpRest.cs
  41. +77 26 Neo4jRestNet/Rest/Neo4jRestApi.cs
  42. +0 13 Neo4jRestNetExamples/App.config
  43. +0 62 Neo4jRestNetExamples/Examples.csproj
  44. +0 196 Neo4jRestNetExamples/Program.cs
  45. +0 36 Neo4jRestNetExamples/Properties/AssemblyInfo.cs
25 Neo4jRestNet.Test/App.config
... ... @@ -1,13 +1,26 @@
1 1 <?xml version="1.0" encoding="utf-8" ?>
2 2 <configuration>
3   - <connectionStrings>
4   - <add name="neo4j" connectionString="http://localhost:7474/db/data/" providerName="Neo4j" />
5   - <add name="neo4jGremlinExtension" connectionString="/ext/GremlinPlugin/graphdb/execute_script/" providerName="Neo4j"/>
6   - <add name="neo4jCypherExtension" connectionString="/ext/CypherPlugin/graphdb/execute_query/" providerName="Neo4j"/>
7   - </connectionStrings>
  3 + <configSections>
  4 + <section name="neo4jRestNet" type="Neo4jRestNet.Configuration.ConnectionSettings, Neo4jRestNet" />
  5 + </configSections>
  6 +
  7 + <neo4jRestNet>
  8 + <databases>
  9 + <add name="neo4j" default="true" https="false" domain="localhost" port="7474" dataPath="/db/data" gremlinPath="/ext/GremlinPlugin/graphdb/execute_script" />
  10 + </databases>
  11 + </neo4jRestNet>
8 12
9 13 <appSettings>
10 14 <add key="EncryptIdKey" value="KeyForEncrypting"/>
11 15 <add key="EncryptIdIV" value="IVForEncrypting1"/>
12 16 </appSettings>
13   -</configuration>
  17 +
  18 + <!-- This is required to support escaped '/' and '.' values in the URL (such as looking up an node via a index) -->
  19 + <uri>
  20 + <schemeSettings>
  21 + <add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
  22 + <add name="https" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
  23 + </schemeSettings>
  24 + </uri>
  25 +</configuration>
  26 +
791 Neo4jRestNet.Test/BatchStoreTest.cs
... ... @@ -0,0 +1,791 @@
  1 +using System;
  2 +using System.Collections;
  3 +using System.Text;
  4 +using System.Collections.Generic;
  5 +using System.Linq;
  6 +using Microsoft.VisualStudio.TestTools.UnitTesting;
  7 +using Neo4jRestNet.Core;
  8 +using Neo4jRestNet.Core.Exceptions;
  9 +
  10 +namespace Neo4jRestNet.Test
  11 +{
  12 + [TestClass]
  13 + public class BatchStoreTest
  14 + {
  15 + private string UniqueValue()
  16 + {
  17 + return System.Web.Security.Membership.GeneratePassword(5, 0);
  18 + }
  19 +
  20 + [TestMethod]
  21 + public void CreateNodeNoProperties()
  22 + {
  23 + var batch = new BatchStore();
  24 + var batchNode = Node.CreateNode(null, batch);
  25 +
  26 + Assert.IsTrue(batch.Execute());
  27 +
  28 + var restNode = batch.GetGraphObject(batchNode);
  29 +
  30 + Assert.IsTrue(restNode.Id > 0);
  31 + }
  32 +
  33 + [TestMethod]
  34 + public void CreateTwoNodeNoProperties()
  35 + {
  36 + var batch = new BatchStore();
  37 + var batchNode1 = Node.CreateNode(batch);
  38 + var batchNode2 = Node.CreateNode(batch);
  39 +
  40 + Assert.IsTrue(batch.Execute());
  41 +
  42 + var restNode1 = batch.GetGraphObject(batchNode1);
  43 + var restNode2 = batch.GetGraphObject(batchNode2);
  44 +
  45 + Assert.IsTrue(restNode1.Id > 0);
  46 + Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
  47 + }
  48 +
  49 + [TestMethod]
  50 + public void CreateNodeWithProperties()
  51 + {
  52 + var batch = new BatchStore();
  53 +
  54 + var prop1 = new Properties();
  55 + prop1.SetProperty("name", "michael");
  56 + prop1.SetProperty("location", "new york");
  57 +
  58 + var prop2 = new Properties();
  59 + prop2.SetProperty("color", "blue");
  60 + prop2.SetProperty("tree", "elm");
  61 +
  62 + var batchNode1 = Node.CreateNode(prop1, batch);
  63 + var batchNode2 = Node.CreateNode(prop2, batch);
  64 +
  65 + Assert.IsTrue(batch.Execute());
  66 +
  67 + var restNode1 = batch.GetGraphObject(batchNode1);
  68 + var restNode2 = batch.GetGraphObject(batchNode2);
  69 +
  70 + Assert.IsTrue(restNode1.Id > 0);
  71 + Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
  72 +
  73 + Assert.IsTrue(restNode1.Properties.GetProperty<string>("name") == "michael");
  74 + Assert.IsTrue(restNode1.Properties.GetProperty<string>("location") == "new york");
  75 +
  76 + Assert.IsTrue(restNode2.Properties.GetProperty<string>("color") == "blue");
  77 + Assert.IsTrue(restNode2.Properties.GetProperty<string>("tree") == "elm");
  78 + }
  79 +
  80 + [TestMethod]
  81 + public void GetNode()
  82 + {
  83 + var node = Node.CreateNode();
  84 +
  85 + var batch = new BatchStore();
  86 + var batchNode = Node.GetNode(node.Id, batch);
  87 +
  88 + Assert.IsTrue(batch.Execute());
  89 +
  90 + var restNode = batch.GetGraphObject(batchNode);
  91 +
  92 + Assert.IsTrue(node == restNode);
  93 + }
  94 +
  95 + [TestMethod]
  96 + [ExpectedException(typeof(NodeNotFoundException))]
  97 + public void DeleteNode()
  98 + {
  99 + var node = Node.CreateNode();
  100 +
  101 + var batch = new BatchStore();
  102 +
  103 + batch.Delete(node);
  104 +
  105 + Assert.IsTrue(batch.Execute());
  106 +
  107 + Node.GetNode(node.Id);
  108 + }
  109 +
  110 + [TestMethod]
  111 + [ExpectedException(typeof(BatchDeleteNotSupportedException))]
  112 + public void DeleteBatchNode1()
  113 + {
  114 + var batch = new BatchStore();
  115 + var node = Node.CreateNode(batch);
  116 +
  117 + node.Delete();
  118 +
  119 + batch.Execute();
  120 + }
  121 +
  122 + [TestMethod]
  123 + [ExpectedException(typeof(BatchDeleteNotSupportedException))]
  124 + public void DeleteBatchNode2()
  125 + {
  126 + var batch = new BatchStore();
  127 + var node = Node.CreateNode(batch);
  128 +
  129 + batch.Delete(node);
  130 + batch.Execute();
  131 + }
  132 +
  133 + [TestMethod]
  134 + public void CreateRelationshipNoProperties1()
  135 + {
  136 + var batch = new BatchStore();
  137 + var batchNode1 = Node.CreateNode(batch);
  138 + var batchNode2 = Node.CreateNode(batch);
  139 +
  140 + var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "friend");
  141 +
  142 + Assert.IsTrue(batch.Execute());
  143 +
  144 + var restNode1 = batch.GetGraphObject(batchNode1);
  145 + var restNode2 = batch.GetGraphObject(batchNode2);
  146 + var restRelationship = batch.GetGraphObject(batchRelationship);
  147 +
  148 + Assert.IsTrue(restNode1.Id > 0);
  149 + Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
  150 +
  151 + Assert.IsTrue(restRelationship.StartNode == restNode1);
  152 + Assert.IsTrue(restRelationship.EndNode == restNode2);
  153 + Assert.IsTrue(restRelationship.Type == "friend");
  154 + }
  155 +
  156 + [TestMethod]
  157 + public void CreateRelationshipNoProperties2()
  158 + {
  159 + var batch = new BatchStore();
  160 + var batchNode1 = Node.CreateNode(batch);
  161 + var batchNode2 = Node.CreateNode(batch);
  162 +
  163 + var batchRelationship = Relationship.CreateRelationship(batchNode1, batchNode2, "friend", null, batch);
  164 +
  165 + Assert.IsTrue(batch.Execute());
  166 +
  167 + var restNode1 = batch.GetGraphObject(batchNode1);
  168 + var restNode2 = batch.GetGraphObject(batchNode2);
  169 + var restRelationship = batch.GetGraphObject(batchRelationship);
  170 +
  171 + Assert.IsTrue(restNode1.Id > 0);
  172 + Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
  173 +
  174 + Assert.IsTrue(restRelationship.StartNode == restNode1);
  175 + Assert.IsTrue(restRelationship.EndNode == restNode2);
  176 + Assert.IsTrue(restRelationship.Type == "friend");
  177 + }
  178 +
  179 + [TestMethod]
  180 + public void CreateRelationshipWithProperties1()
  181 + {
  182 + var batch = new BatchStore();
  183 + var batchNode1 = Node.CreateNode(batch);
  184 + var batchNode2 = Node.CreateNode(batch);
  185 +
  186 + var prop = new Properties();
  187 +
  188 + var since = DateTime.Now;
  189 +
  190 + prop.SetProperty("since", since);
  191 + prop.SetProperty("approved", true);
  192 +
  193 + var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "friend", prop);
  194 +
  195 + Assert.IsTrue(batch.Execute());
  196 +
  197 + var restNode1 = batch.GetGraphObject(batchNode1);
  198 + var restNode2 = batch.GetGraphObject(batchNode2);
  199 + var restRelationship = batch.GetGraphObject(batchRelationship);
  200 +
  201 + Assert.IsTrue(restNode1.Id > 0);
  202 + Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
  203 +
  204 + Assert.IsTrue(restRelationship.StartNode == restNode1);
  205 + Assert.IsTrue(restRelationship.EndNode == restNode2);
  206 + Assert.IsTrue(restRelationship.Type == "friend");
  207 +
  208 + Assert.IsTrue(restRelationship.Properties.GetProperty<DateTime>("since") == since);
  209 + Assert.IsTrue(restRelationship.Properties.GetProperty<bool>("approved"));
  210 + }
  211 +
  212 + [TestMethod]
  213 + public void CreateRelationshipWithProperties2()
  214 + {
  215 + var batch = new BatchStore();
  216 + var batchNode1 = Node.CreateNode(batch);
  217 + var batchNode2 = Node.CreateNode(batch);
  218 +
  219 + var prop = new Properties();
  220 +
  221 + var since = DateTime.Now;
  222 +
  223 + prop.SetProperty("since", since);
  224 + prop.SetProperty("approved", true);
  225 +
  226 + var batchRelationship = Relationship.CreateRelationship(batchNode1, batchNode2, "friend", prop, batch);
  227 +
  228 + Assert.IsTrue(batch.Execute());
  229 +
  230 + var restNode1 = batch.GetGraphObject(batchNode1);
  231 + var restNode2 = batch.GetGraphObject(batchNode2);
  232 + var restRelationship = batch.GetGraphObject(batchRelationship);
  233 +
  234 + Assert.IsTrue(restNode1.Id > 0);
  235 + Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
  236 +
  237 + Assert.IsTrue(restRelationship.StartNode == restNode1);
  238 + Assert.IsTrue(restRelationship.EndNode == restNode2);
  239 + Assert.IsTrue(restRelationship.Type == "friend");
  240 +
  241 + Assert.IsTrue(restRelationship.Properties.GetProperty<DateTime>("since") == since);
  242 + Assert.IsTrue(restRelationship.Properties.GetProperty<bool>("approved"));
  243 + }
  244 +
  245 +
  246 + [TestMethod]
  247 + public void GetRelationshipWithProperties()
  248 + {
  249 + var node1 = Node.CreateNode();
  250 + var node2 = Node.CreateNode();
  251 +
  252 + var props = new Properties();
  253 + props.SetProperty("name", "michael");
  254 + props.SetProperty("approved", true);
  255 + props.SetProperty("length", 123);
  256 +
  257 + var relationship = node1.CreateRelationshipTo(node2, "friend", props);
  258 +
  259 + var batch = new BatchStore();
  260 + var batchRelationship = Relationship.GetRelationship(relationship.Id, batch);
  261 +
  262 + Assert.IsTrue(batch.Execute());
  263 +
  264 + var restRelationship = batch.GetGraphObject(batchRelationship);
  265 +
  266 + Assert.IsTrue(restRelationship == relationship);
  267 + Assert.IsTrue(restRelationship.Properties.GetProperty<string>("name") == "michael");
  268 + Assert.IsTrue(restRelationship.Properties.GetProperty<bool>("approved"));
  269 + Assert.IsTrue(restRelationship.Properties.GetProperty<int>("length") == 123);
  270 + }
  271 +
  272 + [TestMethod]
  273 + public void UpdateRelationshipProperties1()
  274 + {
  275 + var node1 = Node.CreateNode();
  276 + var node2 = Node.CreateNode();
  277 +
  278 + var batch = new BatchStore();
  279 +
  280 + var batchRelationship = Relationship.CreateRelationship(node1, node2, "likes", null, batch);
  281 +
  282 + batchRelationship.Properties.SetProperty("name", "todd");
  283 + batchRelationship.Properties.SetProperty("moved", true);
  284 + batchRelationship.Properties.SetProperty("height", 13);
  285 +
  286 + batchRelationship.SaveProperties();
  287 +
  288 + Assert.IsTrue(batch.Execute());
  289 +
  290 + var restRelationship = batch.GetGraphObject(batchRelationship);
  291 +
  292 + Assert.IsTrue(restRelationship.Properties.GetProperty<string>("name") == "todd");
  293 + Assert.IsTrue(restRelationship.Properties.GetProperty<bool>("moved"));
  294 + Assert.IsTrue(restRelationship.Properties.GetProperty<int>("height") == 13);
  295 + }
  296 +
  297 + [TestMethod]
  298 + public void RemoveRelationshipProperties()
  299 + {
  300 + var node1 = Node.CreateNode();
  301 + var node2 = Node.CreateNode();
  302 +
  303 + var batch = new BatchStore();
  304 +
  305 + var batchRelationship = Relationship.CreateRelationship(node1, node2, "likes", null, batch);
  306 + batchRelationship.Properties.SetProperty("name", "joe");
  307 + batchRelationship.Properties.SetProperty("age", 12);
  308 +
  309 + batchRelationship.SaveProperties();
  310 +
  311 + batchRelationship.Properties.RemoveProperty("age");
  312 +
  313 + batchRelationship.SaveProperties();
  314 +
  315 + Assert.IsTrue(batch.Execute());
  316 +
  317 + var restRelationship = batch.GetGraphObject(batchRelationship);
  318 +
  319 + Assert.IsTrue(restRelationship.Properties.GetProperty<string>("name") == "joe");
  320 + Assert.IsTrue(restRelationship.Properties.GetPropertyOrDefault<int>("age") == 0);
  321 + }
  322 +
  323 +
  324 + [TestMethod]
  325 + [ExpectedException(typeof(BatchGetRelationshipsNotSupportedException))]
  326 + public void GetAllRelationships1()
  327 + {
  328 + var batch = new BatchStore();
  329 +
  330 + var batchNode = Node.CreateNode(batch);
  331 + batchNode.GetRelationships();
  332 +
  333 + batch.Execute();
  334 + }
  335 +
  336 + [TestMethod]
  337 + public void GetAllRelationships2()
  338 + {
  339 + var node1 = Node.CreateNode();
  340 + var node2 = Node.CreateNode();
  341 + var node3 = Node.CreateNode();
  342 + var node4 = Node.CreateNode();
  343 +
  344 + var restRelationship1 = node1.CreateRelationshipTo(node2, "like");
  345 + var restRelationship2 = node1.CreateRelationshipTo(node3, "like");
  346 + var restRelationship3 = node1.CreateRelationshipTo(node4, "like");
  347 +
  348 + var batch = new BatchStore();
  349 + var batchRelationships = batch.GetRelationships(node1, RelationshipDirection.All);
  350 +
  351 + Assert.IsTrue(batch.Execute());
  352 +
  353 + var restRelationships = batch.GetGraphObject(batchRelationships);
  354 +
  355 + Assert.IsNotNull(restRelationships);
  356 +
  357 + Assert.IsTrue(restRelationships.Count() == 3);
  358 + }
  359 +
  360 + [TestMethod]
  361 + public void UpdatePropertyOnNode1()
  362 + {
  363 + var batch = new BatchStore();
  364 + var batchNode = Node.CreateNode(batch);
  365 +
  366 + var props = new Properties();
  367 + props.SetProperty("name", "todd");
  368 + props.SetProperty("moved", true);
  369 + props.SetProperty("height", 13);
  370 +
  371 + batchNode.SaveProperties(props);
  372 +
  373 + Assert.IsTrue(batch.Execute());
  374 +
  375 + var restNode = batch.GetGraphObject(batchNode);
  376 +
  377 + Assert.IsTrue(restNode.Properties.GetProperty<string>("name") == "todd");
  378 + Assert.IsTrue(restNode.Properties.GetProperty<bool>("moved"));
  379 + Assert.IsTrue(restNode.Properties.GetProperty<int>("height") == 13);
  380 + }
  381 +
  382 + [TestMethod]
  383 + public void UpdatePropertyOnNode2()
  384 + {
  385 + var batch = new BatchStore();
  386 +
  387 + var batchNode = Node.CreateNode(batch);
  388 +
  389 + batchNode.Properties.SetProperty("name", "todd");
  390 + batchNode.Properties.SetProperty("moved", true);
  391 + batchNode.Properties.SetProperty("height", 13);
  392 +
  393 + batchNode.SaveProperties();
  394 +
  395 + Assert.IsTrue(batch.Execute());
  396 +
  397 + var restNode = batch.GetGraphObject(batchNode);
  398 +
  399 + Assert.IsTrue(restNode.Properties.GetProperty<string>("name") == "todd");
  400 + Assert.IsTrue(restNode.Properties.GetProperty<bool>("moved"));
  401 + Assert.IsTrue(restNode.Properties.GetProperty<int>("height") == 13);
  402 + }
  403 +
  404 + [TestMethod]
  405 + public void GetPropertiesOnNode1()
  406 + {
  407 + var batch = new BatchStore();
  408 +
  409 + var node = Node.CreateNode();
  410 +
  411 + node.Properties.SetProperty("name", "todd");
  412 + node.Properties.SetProperty("moved", true);
  413 + node.Properties.SetProperty("height", 13);
  414 +
  415 + node.SaveProperties();
  416 +
  417 + var batchNode = Node.GetNode(node.Id, batch);
  418 +
  419 + Assert.IsTrue(batch.Execute());
  420 +
  421 + var restNode = batch.GetGraphObject(batchNode);
  422 +
  423 + Assert.IsTrue(restNode.Properties.GetProperty<string>("name") == "todd");
  424 + Assert.IsTrue(restNode.Properties.GetProperty<bool>("moved"));
  425 + Assert.IsTrue(restNode.Properties.GetProperty<int>("height") == 13);
  426 + }
  427 +
  428 + [TestMethod]
  429 + public void DeleteAPropertyFromNode()
  430 + {
  431 + var batch = new BatchStore();
  432 +
  433 + var batchNode = Node.CreateNode(batch);
  434 +
  435 + batchNode.Properties.SetProperty("name", "todd");
  436 + batchNode.Properties.SetProperty("moved", true);
  437 + batchNode.Properties.SetProperty("height", 13);
  438 +
  439 + batchNode.SaveProperties();
  440 +
  441 + batchNode.Properties.RemoveProperty("moved");
  442 +
  443 + batchNode.SaveProperties();
  444 +
  445 + Assert.IsTrue(batch.Execute());
  446 +
  447 + var restNode = batch.GetGraphObject(batchNode);
  448 +
  449 + Assert.IsTrue(restNode.Properties.GetProperty<string>("name") == "todd");
  450 + Assert.IsFalse(restNode.Properties.GetPropertyOrDefault<bool>("moved"));
  451 + Assert.IsTrue(restNode.Properties.GetProperty<int>("height") == 13);
  452 + }
  453 +
  454 + [TestMethod]
  455 + public void AddNodeToIndex()
  456 + {
  457 + var batch = new BatchStore();
  458 +
  459 + var batchNode = Node.CreateNode(batch);
  460 +
  461 + var value1 = UniqueValue();
  462 +
  463 + batchNode.AddToIndex("nodes", "a", value1);
  464 +
  465 + Assert.IsTrue(batch.Execute());
  466 +
  467 + var restNode = batch.GetGraphObject(batchNode);
  468 +
  469 + var nodes = Node.GetNode("nodes", "a", value1);
  470 + Assert.IsTrue(nodes.Count() == 1);
  471 + Assert.IsTrue(nodes.First() == restNode);
  472 + }
  473 +
  474 + [TestMethod]
  475 + public void AddRelationshipsToIndex()
  476 + {
  477 + var batch = new BatchStore();
  478 +
  479 + var batchNode1 = Node.CreateNode(batch);
  480 + var batchNode2 = Node.CreateNode(batch);
  481 +
  482 + var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "friend");
  483 +
  484 + var value1 = UniqueValue();
  485 +
  486 + batchRelationship.AddToIndex("relationships", "a", value1);
  487 +
  488 + Assert.IsTrue(batch.Execute());
  489 +
  490 + var restRelationship = batch.GetGraphObject(batchRelationship);
  491 +
  492 + var relationships = Relationship.GetRelationship("relationships", "a", value1);
  493 + Assert.IsTrue(relationships.Count() == 1);
  494 + Assert.IsTrue(relationships.First() == restRelationship);
  495 + }
  496 +
  497 + [TestMethod]
  498 + [ExpectedException(typeof(BatchRemoveFromIndexNotSupportedException))]
  499 + public void RemoveNodeToIndex1()
  500 + {
  501 + var batch = new BatchStore();
  502 +
  503 + var batchNode = Node.CreateNode(batch);
  504 +
  505 + var value1 = UniqueValue();
  506 + var value2 = UniqueValue();
  507 +
  508 + batchNode.AddToIndex("nodes", "a", value1);
  509 +
  510 + batchNode.RemoveFromIndex("nodes");
  511 + }
  512 +
  513 + [TestMethod]
  514 + public void RemoveNodeToIndex2()
  515 + {
  516 + var batch = new BatchStore();
  517 +
  518 + var node = Node.CreateNode();
  519 +
  520 + var value1 = UniqueValue();
  521 + var value2 = UniqueValue();
  522 +
  523 + node.AddToIndex("nodes", "a", value1);
  524 + node.AddToIndex("nodes", "b", value2);
  525 +
  526 + Node.RemoveFromIndex(node, "nodes", null, null, batch);
  527 +
  528 + Assert.IsTrue(batch.Execute());
  529 +
  530 + var nodes1 = Node.GetNode("nodes", "a", value1);
  531 + var nodes2 = Node.GetNode("nodes", "b", value2);
  532 +
  533 + Assert.IsTrue(!nodes1.Any());
  534 + Assert.IsTrue(!nodes2.Any());
  535 + }
  536 +
  537 + [TestMethod]
  538 + public void RemoveNodeToIndex3()
  539 + {
  540 + var batch = new BatchStore();
  541 +
  542 + var node = Node.CreateNode();
  543 +
  544 + var value1 = UniqueValue();
  545 +
  546 + node.AddToIndex("nodes", "a", value1);
  547 + node.AddToIndex("nodes", "b", value1);
  548 +
  549 + Node.RemoveFromIndex(node, "nodes", "a", null, batch);
  550 +
  551 + Assert.IsTrue(batch.Execute());
  552 +
  553 + var nodes1 = Node.GetNode("nodes", "a", value1);
  554 + var nodes2 = Node.GetNode("nodes", "b", value1);
  555 +
  556 + Assert.IsTrue(!nodes1.Any());
  557 + Assert.IsTrue(nodes2.Count() == 1);
  558 + Assert.IsTrue(nodes2.First() == node);
  559 + }
  560 +
  561 + [TestMethod]
  562 + public void RemoveNodeToIndex4()
  563 + {
  564 + var batch = new BatchStore();
  565 +
  566 + var node = Node.CreateNode();
  567 +
  568 + var value1 = UniqueValue();
  569 + var value2 = UniqueValue();
  570 +
  571 + node.AddToIndex("nodes", "a", value1);
  572 + node.AddToIndex("nodes", "a", value2);
  573 + node.AddToIndex("nodes", "b", value2);
  574 +
  575 + Node.RemoveFromIndex(node, "nodes", "a", value2, batch);
  576 +
  577 + Assert.IsTrue(batch.Execute());
  578 +
  579 + var nodes1 = Node.GetNode("nodes", "a", value1);
  580 + var nodes2 = Node.GetNode("nodes", "a", value2);
  581 + var nodes3 = Node.GetNode("nodes", "b", value2);
  582 +
  583 + Assert.IsTrue(nodes1.Count() == 1);
  584 + Assert.IsTrue(nodes2.Count() == 0);
  585 + Assert.IsTrue(nodes3.Count() == 1);
  586 +
  587 + Assert.IsTrue(nodes1.First() == node);
  588 + Assert.IsTrue(nodes3.First() == node);
  589 + }
  590 +
  591 + [TestMethod]
  592 + [ExpectedException(typeof(BatchRemoveFromIndexNotSupportedException))]
  593 + public void RemoveRelationshpToIndex1()
  594 + {
  595 + var batch = new BatchStore();
  596 +
  597 + var batchNode1 = Node.CreateNode(batch);
  598 + var batchNode2 = Node.CreateNode(batch);
  599 + var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "like");
  600 +
  601 + var value1 = UniqueValue();
  602 +
  603 + batchRelationship.AddToIndex("relationships", "a", value1);
  604 +
  605 + batchRelationship.RemoveFromIndex("nodes");
  606 + }
  607 +
  608 + [TestMethod]
  609 + public void RemoveRelationshpToIndex2()
  610 + {
  611 + var batch = new BatchStore();
  612 +
  613 + var node1 = Node.CreateNode();
  614 + var node2 = Node.CreateNode();
  615 +
  616 + var relationship1 = node1.CreateRelationshipTo(node2, "like");
  617 +
  618 + var value1 = UniqueValue();
  619 + var value2 = UniqueValue();
  620 +
  621 + relationship1.AddToIndex("relationships", "a", value1);
  622 + relationship1.AddToIndex("relationships", "b", value2);
  623 +
  624 + Relationship.RemoveFromIndex(relationship1, "relationships", null, null, batch);
  625 +
  626 + Assert.IsTrue(batch.Execute());
  627 +
  628 + var relationships1 = Relationship.GetRelationship("relationships", "a", value1);
  629 + var relationships2 = Relationship.GetRelationship("relationships", "b", value2);
  630 +
  631 + Assert.IsTrue(!relationships1.Any());
  632 + Assert.IsTrue(!relationships2.Any());
  633 + }
  634 +
  635 + [TestMethod]
  636 + public void RemoveRelationshipToIndex3()
  637 + {
  638 + var batch = new BatchStore();
  639 +
  640 + var node1 = Node.CreateNode();
  641 + var node2 = Node.CreateNode();
  642 +
  643 + var relationship1 = node1.CreateRelationshipTo(node2, "like");
  644 +
  645 + var value1 = UniqueValue();
  646 +
  647 + relationship1.AddToIndex("relationships", "a", value1);
  648 + relationship1.AddToIndex("relationships", "b", value1);
  649 +
  650 + Relationship.RemoveFromIndex(relationship1, "relationships", "a", null, batch);
  651 +
  652 + Assert.IsTrue(batch.Execute());
  653 +
  654 + var relationships1 = Relationship.GetRelationship("relationships", "a", value1);
  655 + var relationships2 = Relationship.GetRelationship("relationships", "b", value1);
  656 +
  657 + Assert.IsTrue(!relationships1.Any());
  658 + Assert.IsTrue(relationships2.Count() == 1);
  659 + Assert.IsTrue(relationships2.First() == relationship1);
  660 + }
  661 +
  662 + [TestMethod]
  663 + public void RemoveRelationshipToIndex4()
  664 + {
  665 + var batch = new BatchStore();
  666 +
  667 + var node1 = Node.CreateNode();
  668 + var node2 = Node.CreateNode();
  669 +
  670 + var relationship1 = node1.CreateRelationshipTo(node2, "like");
  671 +
  672 + var value1 = UniqueValue();
  673 + var value2 = UniqueValue();
  674 +
  675 + relationship1.AddToIndex("relationships", "a", value1);
  676 + relationship1.AddToIndex("relationships", "a", value2);
  677 + relationship1.AddToIndex("relationships", "b", value2);
  678 +
  679 + Relationship.RemoveFromIndex(relationship1, "relationships", "a", value2, batch);
  680 +
  681 + Assert.IsTrue(batch.Execute());
  682 +
  683 + var relationships1 = Relationship.GetRelationship("relationships", "a", value1);
  684 + var relationships2 = Relationship.GetRelationship("relationships", "a", value2);
  685 + var relationships3 = Relationship.GetRelationship("relationships", "b", value2);
  686 +
  687 + Assert.IsTrue(relationships1.Count() == 1);
  688 + Assert.IsTrue(relationships2.Count() == 0);
  689 + Assert.IsTrue(relationships3.Count() == 1);
  690 +
  691 + Assert.IsTrue(relationships1.First() == relationship1);
  692 + Assert.IsTrue(relationships3.First() == relationship1);
  693 + }
  694 +
  695 + [TestMethod]
  696 + public void AddNodeToIndexUnique1()
  697 + {
  698 + var batch = new BatchStore();
  699 +
  700 + var batchNode = Node.CreateNode(batch);
  701 +
  702 + var value1 = UniqueValue();
  703 +
  704 + var batchUniqueNode = batchNode.AddToIndex("nodes", "a", value1, true);
  705 +
  706 + Assert.IsTrue(batch.Execute());
  707 +
  708 + var restNode = batch.GetGraphObject(batchUniqueNode);
  709 +
  710 + var nodes = Node.GetNode("nodes", "a", value1);
  711 + Assert.IsTrue(nodes.Count() == 1);
  712 + Assert.IsTrue(nodes.First() == restNode);
  713 + }
  714 +
  715 + [TestMethod]
  716 + public void AddNodeToIndexUnique2()
  717 + {
  718 + var batch = new BatchStore();
  719 +
  720 + var batchNode1 = Node.CreateNode(batch);
  721 + var batchNode2 = Node.CreateNode(batch);
  722 +
  723 + var value1 = UniqueValue();
  724 +
  725 + var batchUniqueNode1 = batchNode1.AddToIndex("nodes", "a", value1, true);
  726 + var batchUniqueNode2 = batchNode2.AddToIndex("nodes", "a", value1, true);
  727 +
  728 + Assert.IsTrue(batch.Execute());
  729 +
  730 + var restNode1 = batch.GetGraphObject(batchUniqueNode1);
  731 + var restNode2 = batch.GetGraphObject(batchUniqueNode2);
  732 +
  733 + var nodes = Node.GetNode("nodes", "a", value1);
  734 + Assert.IsTrue(nodes.Count() == 1);
  735 + Assert.IsTrue(nodes.First() == restNode1);
  736 + Assert.IsTrue(restNode1 == restNode2);
  737 + }
  738 +
  739 + [TestMethod]
  740 + public void CreateUniqueNodeInIndex1()
  741 + {
  742 + var batch = new BatchStore();
  743 +
  744 + var value1 = UniqueValue();
  745 +
  746 + var props = new Properties();
  747 + props.SetProperty("name", "jack");
  748 +
  749 + var batchNode = Node.CreateUniqueNode("nodes", "a", value1, props, batch);
  750 +
  751 + Assert.IsTrue(batch.Execute());
  752 +
  753 + var restNode = batch.GetGraphObject(batchNode);
  754 +
  755 + var nodes = Node.GetNode("nodes", "a", value1);
  756 +
  757 + Assert.IsTrue(nodes.Count() == 1);
  758 + Assert.IsTrue(nodes.First() == restNode);
  759 + Assert.IsTrue(restNode.Properties.GetProperty<string>("name") == "jack");
  760 + }
  761 +
  762 + [TestMethod]
  763 + public void CreateUniqueNodeInIndex2()
  764 + {
  765 + var batch = new BatchStore();
  766 +
  767 + var value1 = UniqueValue();
  768 +
  769 + var props1 = new Properties();
  770 + props1.SetProperty("name", "jack");
  771 +
  772 + var props2 = new Properties();
  773 + props2.SetProperty("name", "frank");
  774 +
  775 + var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, props1, batch);
  776 + var batchNode2 = Node.CreateUniqueNode("nodes", "a", value1, props2, batch);
  777 +
  778 + Assert.IsTrue(batch.Execute());
  779 +
  780 + var restNode1 = batch.GetGraphObject(batchNode1);
  781 + var restNode2 = batch.GetGraphObject(batchNode2);
  782 +
  783 + var nodes = Node.GetNode("nodes", "a", value1);
  784 +
  785 + Assert.IsTrue(nodes.Count() == 1);
  786 + Assert.IsTrue(nodes.First() == restNode1);
  787 + Assert.IsTrue(restNode1 == restNode2);
  788 + Assert.IsTrue(restNode1.Properties.GetProperty<string>("name") == "jack");
  789 + }
  790 + }
  791 +}
36 Neo4jRestNet.Test/EncryptedIDTest.cs
... ... @@ -1,12 +1,6 @@
1   -using System;
2   -using System.Text;
3   -using System.Collections.Generic;
4   -using System.Linq;
5   -using Microsoft.VisualStudio.TestTools.UnitTesting;
  1 +using Microsoft.VisualStudio.TestTools.UnitTesting;
6 2 using Neo4jRestNet.Core;
7 3 using System.Security.Cryptography;
8   -using Neo4jRestNet.Core.Implementation;
9   -using Neo4jRestNet.GremlinPlugin;
10 4
11 5 namespace Neo4jRestNet.Test
12 6 {
@@ -28,7 +22,7 @@ public void GetNode()
28 22 [TestMethod]
29 23 public void NewGEIDFromLong()
30 24 {
31   - EncryptId geid = new EncryptId(123);
  25 + var geid = new EncryptId(123);
32 26
33 27 Assert.AreEqual(123, (long)geid);
34 28 }
@@ -36,10 +30,10 @@ public void NewGEIDFromLong()
36 30 [TestMethod]
37 31 public void NewGEIDFromString()
38 32 {
39   - EncryptId geid = new EncryptId(123);
  33 + var geid = new EncryptId(123);
40 34 string strGEID = geid.ToString();
41 35
42   - EncryptId impGEID = new EncryptId(strGEID);
  36 + var impGEID = new EncryptId(strGEID);
43 37
44 38 Assert.AreEqual(strGEID, impGEID.ToString());
45 39 Assert.AreEqual(strGEID, impGEID.ToString());
@@ -48,8 +42,8 @@ public void NewGEIDFromString()
48 42 [TestMethod]
49 43 public void TryParseValid()
50 44 {
51   - EncryptId geid = new EncryptId(123);
52   - string strGEID = geid.ToString();
  45 + var geid = new EncryptId(123);
  46 + var strGEID = geid.ToString();
53 47
54 48 EncryptId tryGEID;
55 49 Assert.IsTrue(EncryptId.TryParse(strGEID, out tryGEID));
@@ -59,7 +53,7 @@ public void TryParseValid()
59 53 [TestMethod]
60 54 public void TryParseNotValid()
61 55 {
62   - string strGEID = "SomeBadValue";
  56 + var strGEID = "SomeBadValue";
63 57
64 58 EncryptId tryGEID;
65 59 Assert.IsFalse(EncryptId.TryParse(strGEID, out tryGEID));
@@ -75,9 +69,9 @@ public void ImplicitBadStringValue()
75 69 [TestMethod]
76 70 public void Equality()
77 71 {
78   - EncryptId geid1 = new EncryptId(123);
79   - EncryptId geid2 = new EncryptId(123);
80   - EncryptId geid3 = new EncryptId(321);
  72 + var geid1 = new EncryptId(123);
  73 + var geid2 = new EncryptId(123);
  74 + var geid3 = new EncryptId(321);
81 75
82 76 Assert.IsTrue(geid1 == geid2);
83 77 Assert.IsTrue(geid1.ToString() == geid2.ToString());
@@ -93,9 +87,9 @@ public void Equality()
93 87 [TestMethod]
94 88 public void Inequality()
95 89 {
96   - EncryptId geid1 = new EncryptId(123);
97   - EncryptId geid2 = new EncryptId(321);
98   - EncryptId geid3 = new EncryptId(123);
  90 + var geid1 = new EncryptId(123);
  91 + var geid2 = new EncryptId(321);
  92 + var geid3 = new EncryptId(123);
99 93
100 94 Assert.IsTrue(geid1 != geid2);
101 95 Assert.IsTrue(geid1.ToString() != geid2.ToString());
@@ -111,8 +105,8 @@ public void Inequality()
111 105 [TestMethod]
112 106 public void NullValue()
113 107 {
114   - EncryptId geidNull = EncryptId.Null;
115   - EncryptId geid = new EncryptId(123);
  108 + var geidNull = EncryptId.Null;
  109 + var geid = new EncryptId(123);
116 110
117 111 Assert.IsTrue(geidNull == EncryptId.Null);
118 112 Assert.IsFalse(geidNull != EncryptId.Null);
8 Neo4jRestNet.Test/Neo4jRestNet.Test.csproj
@@ -35,9 +35,11 @@
35 35 <ItemGroup>
36 36 <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
37 37 <Reference Include="System" />
  38 + <Reference Include="System.configuration" />
38 39 <Reference Include="System.Core">
39 40 <RequiredTargetFramework>3.5</RequiredTargetFramework>
40 41 </Reference>
  42 + <Reference Include="System.Web" />
41 43 </ItemGroup>
42 44 <ItemGroup>
43 45 <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
@@ -45,12 +47,16 @@
45 47 </CodeAnalysisDependentAssemblyPaths>
46 48 </ItemGroup>
47 49 <ItemGroup>
  50 + <Compile Include="BatchStoreTest.cs" />
48 51 <Compile Include="FilterLambdaTest.cs" />
49 52 <Compile Include="Properties\AssemblyInfo.cs" />
50 53 <Compile Include="EncryptedIDTest.cs" />
  54 + <Compile Include="NodeClassTest.cs" />
51 55 </ItemGroup>
52 56 <ItemGroup>
53   - <None Include="App.config" />
  57 + <None Include="App.config">
  58 + <SubType>Designer</SubType>
  59 + </None>
54 60 </ItemGroup>
55 61 <ItemGroup>
56 62 <ProjectReference Include="..\Neo4jRestNet\Neo4jRestNet.csproj">
822 Neo4jRestNet.Test/NodeClassTest.cs
... ... @@ -0,0 +1,822 @@
  1 +using System;
  2 +using System.Text;
  3 +using System.Collections.Generic;
  4 +using System.Linq;
  5 +using Microsoft.VisualStudio.TestTools.UnitTesting;
  6 +using Neo4jRestNet.Core;
  7 +using Neo4jRestNet.Core.Exceptions;
  8 +
  9 +namespace Neo4jRestNet.Test
  10 +{
  11 + [TestClass]
  12 + public class NodeClassTest
  13 + {
  14 + private string UniqueValue()
  15 + {
  16 + return System.Web.Security.Membership.GeneratePassword(5, 0);
  17 + }
  18 +
  19 + [TestMethod]
  20 + public void CreateNode()
  21 + {
  22 + var node = Node.CreateNode();
  23 + Assert.IsNotNull(node);
  24 + }
  25 +
  26 + [TestMethod]
  27 + public void CreateNodeWithNodeType()
  28 + {
  29 + var prop = new Properties();
  30 + prop.SetProperty("NodeType", "myNodeType");
  31 +
  32 + var node = Node.CreateNode(prop);
  33 + Assert.IsNotNull(node);
  34 + Assert.IsTrue(node.Properties.GetProperty<string>("NodeType") == "myNodeType");
  35 + }
  36 +
  37 + [TestMethod]
  38 + public void CreateNodeWithPropertyDictionary()
  39 + {
  40 + var properties = new Dictionary<string, object>();
  41 + properties.Add("A", 0);
  42 + properties.Add("B", "Foobar");
  43 + properties.Add("C", new DateTime(2012, 1, 1));
  44 + var node = Node.CreateNode(new Properties(properties));
  45 + Assert.IsNotNull(node);
  46 + Assert.IsTrue(node.Properties.GetProperty("A").Equals(0));
  47 + Assert.IsTrue(node.Properties.GetProperty("B").Equals("Foobar"));
  48 + Assert.IsTrue(node.Properties.GetProperty("C").Equals(new DateTime(2012, 1, 1).ToString("s")));
  49 + Assert.IsTrue(node.Properties.ToDictionary().Count == 3);
  50 + }
  51 +
  52 + [TestMethod]
  53 + public void CreateNodeWithProperties()
  54 + {
  55 + var properties = new Properties();
  56 + properties.SetProperty("A", 0);
  57 + properties.SetProperty("B", "Foobar");
  58 + properties.SetProperty("C", new DateTime(2012, 1, 1));
  59 + var node = Node.CreateNode(properties);
  60 + Assert.IsNotNull(node);
  61 + Assert.IsTrue(node.Properties.GetProperty("A").Equals(0));
  62 + Assert.IsTrue(node.Properties.GetProperty("B").Equals("Foobar"));
  63 + Assert.IsTrue(node.Properties.GetProperty("C").Equals(new DateTime(2012, 1, 1).ToString("s")));
  64 + Assert.IsTrue(node.Properties.ToDictionary().Count == 3);
  65 + }
  66 +
  67 + [TestMethod]
  68 + public void GetNode()
  69 + {
  70 + var node1 = Node.CreateNode();
  71 + var node2 = Node.GetNode(node1.Id);
  72 + Assert.IsNotNull(node2);
  73 + Assert.IsTrue(node1.Equals(node2));
  74 + }
  75 +
  76 + [TestMethod]
  77 + public void GetNodeWithPropertyDictionary()
  78 + {
  79 + var dicProperties = new Dictionary<string, object>();
  80 + dicProperties.Add("A", 0);
  81 + dicProperties.Add("B", "Foobar");
  82 + dicProperties.Add("C", new DateTime(2012, 1, 1));
  83 +
  84 + var properties = new Properties(dicProperties);
  85 +
  86 + var node1 = Node.CreateNode(properties);
  87 + Assert.IsNotNull(node1);
  88 + Assert.IsTrue(node1.Properties.GetProperty("A").Equals(0));
  89 + Assert.IsTrue(node1.Properties.GetProperty("B").Equals("Foobar"));
  90 + Assert.IsTrue(node1.Properties.GetProperty("C").Equals(new DateTime(2012, 1, 1).ToString("s")));
  91 + Assert.IsTrue(node1.Properties.ToDictionary().Count == 3);
  92 +
  93 + var node2 = Node.GetNode(node1.Id);
  94 + Assert.IsNotNull(node2);
  95 + Assert.IsTrue(node1.Equals(node2));
  96 + Assert.IsTrue(node2.Properties.GetProperty("A").Equals(0));
  97 + Assert.IsTrue(node2.Properties.GetProperty("B").Equals("Foobar"));
  98 + Assert.IsTrue(node2.Properties.GetProperty("C").Equals(new DateTime(2012, 1, 1).ToString("s")));
  99 + Assert.IsTrue(node2.Properties.ToDictionary().Count == 3);
  100 + }
  101 +
  102 + [TestMethod]
  103 + public void GetRootNode()
  104 + {
  105 + var node1 = Node.GetRootNode();
  106 + Assert.IsNotNull(node1);
  107 + }
  108 +
  109 + [TestMethod]
  110 + [ExpectedException(typeof(NodeNotFoundException))]
  111 + public void DeleteNode()
  112 + {
  113 + var node1 = Node.CreateNode();
  114 + node1.Delete();
  115 + Node.GetNode(node1.Id); // Should throw NodeNotFoundException
  116 + }
  117 +
  118 + [TestMethod]
  119 + public void AddNodeToIndex()
  120 + {
  121 + var node1 = Node.CreateNode();
  122 + var node2 = Node.CreateNode();
  123 +
  124 + var value1 = UniqueValue();
  125 + var value2 = UniqueValue();
  126 + var value3 = UniqueValue();
  127 +
  128 + var node3 = Node.AddToIndex(node1, "nodes", "a", value1);
  129 + Assert.IsNotNull(node3);
  130 + Assert.IsTrue(node3.Equals(node1));
  131 +
  132 + var nodes = Node.GetNode("nodes", "a", value1);
  133 + Assert.IsTrue(nodes.Count() == 1);
  134 + Assert.IsTrue(nodes.First() == (node3));
  135 +
  136 + var node4 = Node.AddToIndex(node1, "nodes", "b", value2);
  137 + Assert.IsNotNull(node4);
  138 + Assert.IsTrue(node4 == node1);
  139 +
  140 + var node5 = Node.GetNode("nodes", "b", value2).FirstOrDefault();
  141 + Assert.IsNotNull(node5);
  142 + Assert.IsTrue(node5 == node1);
  143 +
  144 + var node6 = Node.AddToIndex(node1, "nodes", "b", value3);
  145 + Assert.IsNotNull(node6);
  146 + Assert.IsTrue(node6 == node1);
  147 +
  148 + nodes = Node.GetNode("nodes", "b", value3);
  149 + Assert.IsTrue(nodes.Count() == 1);
  150 + Assert.IsTrue(nodes.First() == node1);
  151 +
  152 + var node9 = Node.AddToIndex(node1, "nodes", "a", value1);
  153 + var node10 = Node.AddToIndex(node2, "nodes", "a", value1);
  154 + Assert.IsNotNull(node9);
  155 + Assert.IsTrue(node9.Equals(node1));
  156 + Assert.IsNotNull(node10);
  157 + Assert.IsTrue(node10.Equals(node2));
  158 +
  159 + nodes = Node.GetNode("nodes", "a", value1);
  160 + Assert.IsNotNull(nodes);
  161 +
  162 + Assert.IsTrue(nodes.Count() == 2);
  163 + if (nodes.First() == node1)
  164 + {
  165 + Assert.IsTrue(nodes.First().Equals(node1));
  166 + Assert.IsTrue(nodes.ElementAt(1).Equals(node2));
  167 + }