public void GremlinQueryTextShouldReturnSimpleEdgeStep()
 {
     var reference = new RelationshipReference(123);
     var query = ((IGremlinQuery)reference);
     Assert.AreEqual("g.e(p0)", query.QueryText);
     Assert.AreEqual(123, query.QueryParameters["p0"]);
 }
Esempio n. 2
0
     static void Main(string[] args)
     {
     try{
         GraphClient client = new GraphClient(new Uri("http://localhost:7474/db/data"));
         client.Connect();
         Us us = new Us { Name = "We are Us" };
         NodeReference<Us> usRef = client.Create(us);
         Console.WriteLine("us node.id: {0}", usRef.Id);
         var queryUs = client.Cypher.Start("n", "node(" + usRef.Id + ")").Return<Node<Us>>("n");
         Console.WriteLine("Us node name: {0}\n", queryUs.Results.AsEnumerable<Node<Us>>().First().Data);
         AllYourBase allYourBase = new AllYourBase { Name = "We are all your base" };
         NodeReference<AllYourBase> allYourBaseRef = client.Create(allYourBase);
         Console.WriteLine("AllYourBase node.id: {0}",allYourBaseRef.Id);
         var queryAllYourBase = client.Cypher.Start("n", "node(" + allYourBaseRef.Id + ")").Return<Node<AllYourBase>>("n");
         Console.WriteLine("AllYourBase node name: {0}\n", queryAllYourBase.Results.AsEnumerable<Node<AllYourBase>>().First().Data);
         RelationshipReference areBelongToRef = client.CreateRelationship(allYourBaseRef, new AreBelongTo(usRef));
         var query = client.Cypher.Start("allyourbase", "node(" + allYourBaseRef.Id + ")").Match("allyourbase-[:ARE_BELONG_TO]->us").Return<Node<AllYourBase>>("allyourbase");
         query.ExecuteWithoutResults();
         Console.WriteLine("Result of querying for all your base that belongs to us: {0}", query.Results.AsEnumerable<Node<AllYourBase>>().First().Data.Name);
     }
     catch(Exception ex)
     {
         Console.WriteLine("{0}", ex.Message);
         Console.WriteLine("{0}", ex.InnerException);
     }
     Console.ReadKey();
 }
Esempio n. 3
0
        public void GremlinQueryTextShouldReturnSimpleEdgeStep()
        {
            var reference = new RelationshipReference(123);
            var query     = ((IGremlinQuery)reference);

            Assert.AreEqual("g.e(p0)", query.QueryText);
            Assert.AreEqual(123, query.QueryParameters["p0"]);
        }
 public RelationshipInstance(
     RelationshipReference <TData> reference,
     NodeReference startNodeReference,
     NodeReference endNodeReference,
     string typeKey,
     TData data)
     : base(reference, startNodeReference, endNodeReference, typeKey)
 {
     this.data = data;
 }
        public void ShouldPreserveSlashInRelationshipIndexValue()
        {
            //Arrange
            var indexKeyValues = new Dictionary <string, object>
            {
                { "BarKey", "abc/def" }
            };
            var indexEntries = new List <IndexEntry>
            {
                new IndexEntry
                {
                    Name      = "my_relationships",
                    KeyValues = indexKeyValues,
                }
            };

            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostObjectAsJson("/index/relationship/my_relationships",
                                                 new
                    {
                        key = "BarKey",
                        value = "abc/def",
                        uri = "http://foo/db/data/relationship/123"
                    }),
                    MockResponse.Json(HttpStatusCode.Created,
                                      @"Location: http://foo/db/data/index/relationship/my_relationships/BarKey/abc-def/1234")
                },
                {
                    MockRequest.Delete("/index/relationship/my_relationships/123"),
                    MockResponse.Http((int)HttpStatusCode.NoContent)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                //Act
                var relReference = new RelationshipReference(123);
                graphClient.ReIndex(relReference, indexEntries);

                // Assert
                Assert.Pass("Success.");
            }
        }
        public void ShouldAcceptQuestionMarkInRelationshipIndexValue()
        {
            //Arrange
            var indexKeyValues = new Dictionary<string, object>
                {
                    {"BarKey", "foo?bar"}
                };
            var indexEntries = new List<IndexEntry>
                {
                    new IndexEntry
                        {
                            Name = "my_relationships",
                            KeyValues = indexKeyValues,
                        }
                };

            using (var testHarness = new RestTestHarness
                {
                    {
                        MockRequest.PostObjectAsJson("/index/relationship/my_relationships",
                                                     new
                                                         {
                                                             key = "BarKey",
                                                             value = "foo?bar",
                                                             uri = "http://foo/db/data/relationship/1234"
                                                         }),
                        MockResponse.Json(HttpStatusCode.Created,
                                          @"Location: http://foo/db/data/index/relationship/my_relationships/BarKey/%3f/1234")
                    },
                    {
                        MockRequest.Delete("/index/relationship/my_relationships/1234"),
                        MockResponse.Http((int) HttpStatusCode.NoContent)
                    }
                })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                //Act
                var relReference = new RelationshipReference(1234);
                graphClient.ReIndex(relReference, indexEntries);

                // Assert
                Assert.Pass("Success.");
            }
        }
        public void ShouldReindexRelationshipWithDateTimeOffsetIndexEntry()
        {
            //Arrange
            var indexEntries = new List <IndexEntry>
            {
                new IndexEntry
                {
                    Name      = "my_relationships",
                    KeyValues = new Dictionary <string, object>
                    {
                        { "BarKey", new DateTimeOffset(1000, new TimeSpan(0)) }
                    },
                }
            };

            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostObjectAsJson("/index/relationship/my_relationships",
                                                 new
                    {
                        key = "BarKey",
                        value = "1000",
                        uri = "http://foo/db/data/relationship/1234"
                    }),
                    MockResponse.Json(HttpStatusCode.Created,
                                      @"Location: http://foo/db/data/index/relationship/my_relationships/BarKey/someDateValue/1234")
                },
                {
                    MockRequest.Delete("/index/relationship/my_relationships/1234"),
                    MockResponse.Http((int)HttpStatusCode.NoContent)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                //Act
                var relReference = new RelationshipReference(1234);
                graphClient.ReIndex(relReference, indexEntries);

                // Assert
                Assert.Pass("Success.");
            }
        }
        public void ShouldReindexRelationshipWithIndexEntryContainingSpace()
        {
            //Arrange
            var indexEntries = new List <IndexEntry>
            {
                new IndexEntry
                {
                    Name      = "my_relationships",
                    KeyValues = new Dictionary <string, object>
                    {
                        { "BarKey", "the_value with space" }
                    },
                }
            };

            using (var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostObjectAsJson("/index/relationship/my_relationships",
                                                 new
                    {
                        key = "BarKey",
                        value = "the_value with space",
                        uri = "http://foo/db/data/relationship/1234"
                    }),
                    MockResponse.Json(HttpStatusCode.Created,
                                      @"Location: http://foo/db/data/index/relationship/my_relationships/BarKey/the_value%20with%20space/1234")
                },
                {
                    MockRequest.Delete("/index/relationship/my_relationships/1234"),
                    MockResponse.Http((int)HttpStatusCode.NoContent)
                }
            })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                //Act
                var relReference = new RelationshipReference(1234);
                graphClient.ReIndex(relReference, indexEntries);

                // Assert
            }
        }
 public void DeleteRelationshipShouldFailUnderTransaction()
 {
     var relReference = new RelationshipReference(1);
     ExecuteRestMethodUnderTransaction(client => client.DeleteRelationship(relReference));
 }
Esempio n. 10
0
        public void ShouldImplicitlyCastFromInt()
        {
            RelationshipReference relationshipReference = 3;

            Assert.Equal(3, relationshipReference.Id);
        }
Esempio n. 11
0
        public void EqualsShouldReturnFalseWhenComparingWithDifferentType()
        {
            var lhs = new RelationshipReference(3);

            Assert.False(lhs.Equals(new object()));
        }
Esempio n. 12
0
        public void EqualsShouldReturnFalseWhenComparingWithNull()
        {
            var lhs = new RelationshipReference(3);

            Assert.False(lhs.Equals(null));
        }
Esempio n. 13
0
        public void EqualsOperatorShouldReturnTrueWhenComparingNullWithNull()
        {
            RelationshipReference lhs = null;

            Assert.True(lhs == null);
        }
Esempio n. 14
0
        public void GetRelationshipShouldFailUnderTransaction()
        {
            var relReference = new RelationshipReference <TestNode>(1);

            ExecuteRestMethodUnderTransaction(client => client.Get(relReference));
        }
 private Uri AddPath(Uri startUri, RelationshipReference relationship)
 {
     return startUri.AddPath("relationship").AddPath(relationship.Id.ToString());
 }
 public void EqualsShouldReturnFalseWhenComparingWithNull()
 {
     var lhs = new RelationshipReference(3);
     Assert.IsFalse(lhs.Equals(null));
 }
 public void EqualsShouldReturnFalseWhenComparingWithDifferentType()
 {
     var lhs = new RelationshipReference(3);
     Assert.IsFalse(lhs.Equals(new object()));
 }
 public void EqualsOperatorShouldReturnFalseWhenComparingInstanceWithNull()
 {
     var lhs = new RelationshipReference(3);
     Assert.IsFalse(lhs == null);
 }
 public void GetRelationshipShouldFailUnderTransaction()
 {
     var relReference = new RelationshipReference<TestNode>(1);
     ExecuteRestMethodUnderTransaction(client => client.Get(relReference));
 }
Esempio n. 20
0
        public void GetRelationshipShouldFailUnderTransaction()
        {
            var relReference = new RelationshipReference <TestNode>(1);

            Assert.Throws <InvalidOperationException>(() => ExecuteRestMethodUnderTransaction(client => client.Get(relReference)));
        }
Esempio n. 21
0
 static string FormatValue(RelationshipReference value, CreateParameterCallback createParameterCallback)
 {
     return FormatValue(new[] { value }, createParameterCallback);
 }
Esempio n. 22
0
 public void DeleteRelationshipShouldFailUnderTransaction()
 {
     var relReference = new RelationshipReference(1);
     Assert.That(() => ExecuteRestMethodUnderTransaction(client => client.DeleteRelationship(relReference)), Throws.InvalidOperationException);
 }
        public void ShouldReindexRelationshipWithDateTimeOffsetIndexEntry()
        {
            //Arrange
            var indexEntries = new List<IndexEntry>
                {
                    new IndexEntry
                        {
                            Name = "my_relationships",
                            KeyValues = new Dictionary<string, object>
                                {
                                    {"BarKey", new DateTimeOffset(1000, new TimeSpan(0))}
                                },
                        }
                };

            using (var testHarness = new RestTestHarness
                {
                    {
                        MockRequest.PostObjectAsJson("/index/relationship/my_relationships",
                                                     new
                                                         {
                                                             key = "BarKey",
                                                             value = "1000",
                                                             uri = "http://foo/db/data/relationship/1234"
                                                         }),
                        MockResponse.Json(HttpStatusCode.Created,
                                          @"Location: http://foo/db/data/index/relationship/my_relationships/BarKey/someDateValue/1234")
                    },
                    {
                        MockRequest.Delete("/index/relationship/my_relationships/1234"),
                        MockResponse.Http((int) HttpStatusCode.NoContent)
                    }
                })
            {
                var graphClient = testHarness.CreateAndConnectGraphClient();

                //Act
                var relReference = new RelationshipReference(1234);
                graphClient.ReIndex(relReference, indexEntries);

                // Assert
                Assert.Pass("Success.");
            }
        }
Esempio n. 24
0
        public void DeleteRelationshipShouldFailUnderTransaction()
        {
            var relReference = new RelationshipReference(1);

            ExecuteRestMethodUnderTransaction(client => client.DeleteRelationship(relReference));
        }
Esempio n. 25
0
 private Uri AddPath(Uri startUri, RelationshipReference relationship)
 {
     return(startUri.AddPath("relationship").AddPath(relationship.Id.ToString()));
 }
        public void DeleteRelationshipShouldFailUnderTransaction()
        {
            var relReference = new RelationshipReference(1);

            Assert.That(() => ExecuteRestMethodUnderTransaction(client => client.DeleteRelationship(relReference)), Throws.InvalidOperationException);
        }
Esempio n. 27
0
 static string FormatValue(RelationshipReference value, CreateParameterCallback createParameterCallback)
 {
     return(FormatValue(new[] { value }, createParameterCallback));
 }
Esempio n. 28
0
        public void EqualsOperatorShouldReturnFalseWhenComparingInstanceWithNull()
        {
            var lhs = new RelationshipReference(3);

            Assert.False(lhs == null);
        }