public void ShouldSerializeAllProperties()
        {
            var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostJson("/batch",
                                         @"[{
                          'method': 'POST', 'to' : '/node',
                          'body': {
                            'Foo': 'foo',
                            'Bar': 'bar',
                            'Baz': 'baz'
                          },
                          'id': 0
                        }]"
                                         ),
                    MockResponse.Json(HttpStatusCode.OK,
                                      @"[{'id':0,'location':'http://foo/db/data/node/760','body':{
                          'outgoing_relationships' : 'http://foo/db/data/node/760/relationships/out',
                          'data' : {
                            'Foo' : 'foo',
                            'Bar' : 'bar',
                            'Baz' : 'baz'
                          },
                          'traverse' : 'http://foo/db/data/node/760/traverse/{returnType}',
                          'all_typed_relationships' : 'http://foo/db/data/node/760/relationships/all/{-list|&|types}',
                          'self' : 'http://foo/db/data/node/760',
                          'property' : 'http://foo/db/data/node/760/properties/{key}',
                          'outgoing_typed_relationships' : 'http://foo/db/data/node/760/relationships/out/{-list|&|types}',
                          'properties' : 'http://foo/db/data/node/760/properties',
                          'incoming_relationships' : 'http://foo/db/data/node/760/relationships/in',
                          'extensions' : {
                          },
                          'create_relationship' : 'http://foo/db/data/node/760/relationships',
                          'paged_traverse' : 'http://foo/db/data/node/760/paged/traverse/{returnType}{?pageSize,leaseTime}',
                          'all_relationships' : 'http://foo/db/data/node/760/relationships/all',
                          'incoming_typed_relationships' : 'http://foo/db/data/node/760/relationships/in/{-list|&|types}'
                        },'from':'/node'}]"
                                      )
                }
            };

            var graphClient = testHarness.CreateAndConnectGraphClient();

            graphClient.Create(new TestNode {
                Foo = "foo", Bar = "bar", Baz = "baz"
            });

            testHarness.AssertAllRequestsWereReceived();
        }
        public void ShouldNotThrowANotSupportedExceptionForPre15M02DatabaseWhenThereAreNoIndexEntries()
        {
            var testNode = new TestNode {
                Foo = "foo", Bar = "bar", Baz = "baz"
            };
            var batch = new List <BatchStep>();

            batch.Add(HttpMethod.Post, "/node", testNode);

            var testHarness = new RestTestHarness
            {
                {
                    MockRequest.Get(""),
                    MockResponse.NeoRootPre15M02()
                },
                {
                    MockRequest.PostObjectAsJson("/batch", batch),
                    MockResponse.Json(HttpStatusCode.OK,
                                      @"[{'id':0,'location':'http://foo/db/data/node/760','body':{
                          'outgoing_relationships' : 'http://foo/db/data/node/760/relationships/out',
                          'data' : {
                            'Foo' : 'foo',
                            'Bar' : 'bar',
                            'Baz' : 'baz'
                          },
                          'traverse' : 'http://foo/db/data/node/760/traverse/{returnType}',
                          'all_typed_relationships' : 'http://foo/db/data/node/760/relationships/all/{-list|&|types}',
                          'self' : 'http://foo/db/data/node/760',
                          'property' : 'http://foo/db/data/node/760/properties/{key}',
                          'outgoing_typed_relationships' : 'http://foo/db/data/node/760/relationships/out/{-list|&|types}',
                          'properties' : 'http://foo/db/data/node/760/properties',
                          'incoming_relationships' : 'http://foo/db/data/node/760/relationships/in',
                          'extensions' : {
                          },
                          'create_relationship' : 'http://foo/db/data/node/760/relationships',
                          'paged_traverse' : 'http://foo/db/data/node/760/paged/traverse/{returnType}{?pageSize,leaseTime}',
                          'all_relationships' : 'http://foo/db/data/node/760/relationships/all',
                          'incoming_typed_relationships' : 'http://foo/db/data/node/760/relationships/in/{-list|&|types}'
                        },'from':'/node'}]"
                                      )
                }
            };

            var graphClient = testHarness.CreateAndConnectGraphClient();

            graphClient.Create(testNode, null, null);

            testHarness.AssertAllRequestsWereReceived();
        }
        public void ShouldReturnReferenceToCreatedNodeWithLongId()
        {
            var testNode = new TestNode {
                Foo = "foo", Bar = "bar", Baz = "baz"
            };
            var batch = new List <BatchStep>();

            batch.Add(HttpMethod.Post, "/node", testNode);

            var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostObjectAsJson("/batch", batch),
                    MockResponse.Json(HttpStatusCode.OK,
                                      @"[{'id':0,'location':'http://foo/db/data/node/2157483647','body':{
                          'outgoing_relationships' : 'http://foo/db/data/node/2157483647/relationships/out',
                          'data' : {
                            'Foo' : 'foo',
                            'Bar' : 'bar',
                            'Baz' : 'baz'
                          },
                          'traverse' : 'http://foo/db/data/node/2157483647/traverse/{returnType}',
                          'all_typed_relationships' : 'http://foo/db/data/node/2157483647/relationships/all/{-list|&|types}',
                          'self' : 'http://foo/db/data/node/2157483647',
                          'property' : 'http://foo/db/data/node/2157483647/properties/{key}',
                          'outgoing_typed_relationships' : 'http://foo/db/data/node/2157483647/relationships/out/{-list|&|types}',
                          'properties' : 'http://foo/db/data/node/2157483647/properties',
                          'incoming_relationships' : 'http://foo/db/data/node/2157483647/relationships/in',
                          'extensions' : {
                          },
                          'create_relationship' : 'http://foo/db/data/node/2157483647/relationships',
                          'paged_traverse' : 'http://foo/db/data/node/2157483647/paged/traverse/{returnType}{?pageSize,leaseTime}',
                          'all_relationships' : 'http://foo/db/data/node/2157483647/relationships/all',
                          'incoming_typed_relationships' : 'http://foo/db/data/node/2157483647/relationships/in/{-list|&|types}'
                        },'from':'/node'}]"
                                      )
                }
            };

            var graphClient = testHarness.CreateAndConnectGraphClient();

            var node = graphClient.Create(testNode);

            Assert.AreEqual(2157483647, node.Id);
            testHarness.AssertAllRequestsWereReceived();
        }
        public void ShouldCreateIncomingRelationship()
        {
            var testNode = new TestNode2 {
                Foo = "foo", Bar = "bar"
            };
            var testRelationshipPayload = new TestPayload {
                Foo = "123", Bar = "456", Baz = "789"
            };
            var batch = new List <BatchStep>();

            batch.Add(HttpMethod.Post, "/node", testNode);
            batch.Add(HttpMethod.Post, "/node/789/relationships",
                      new RelationshipTemplate {
                To = "{0}", Data = testRelationshipPayload, Type = "TEST_RELATIONSHIP"
            });

            var testHarness = new RestTestHarness
            {
                {
                    MockRequest.PostObjectAsJson("/batch", batch),
                    MockResponse.Json(HttpStatusCode.OK,
                                      @"[{'id':0,'location':'http://foo/db/data/node/760','body':{
                          'outgoing_relationships' : 'http://foo/db/data/node/760/relationships/out',
                          'data' : {
                            'Foo' : 'foo',
                            'Bar' : 'bar',
                            'Baz' : 'baz'
                          },
                          'traverse' : 'http://foo/db/data/node/760/traverse/{returnType}',
                          'all_typed_relationships' : 'http://foo/db/data/node/760/relationships/all/{-list|&|types}',
                          'self' : 'http://foo/db/data/node/760',
                          'property' : 'http://foo/db/data/node/760/properties/{key}',
                          'outgoing_typed_relationships' : 'http://foo/db/data/node/760/relationships/out/{-list|&|types}',
                          'properties' : 'http://foo/db/data/node/760/properties',
                          'incoming_relationships' : 'http://foo/db/data/node/760/relationships/in',
                          'extensions' : {
                          },
                          'create_relationship' : 'http://foo/db/data/node/760/relationships',
                          'paged_traverse' : 'http://foo/db/data/node/760/paged/traverse/{returnType}{?pageSize,leaseTime}',
                          'all_relationships' : 'http://foo/db/data/node/760/relationships/all',
                          'incoming_typed_relationships' : 'http://foo/db/data/node/760/relationships/in/{-list|&|types}'
                        },'from':'/node'},{'id':1,'location':'http://foo/db/data/relationship/756','body':{
                          'start' : 'http://foo/db/data/node/760',
                          'data' : {
                            'Foo' : 123,
                            'Bar' : 456,
                            'Baz' : 789
                          },
                          'property' : 'http://foo/db/data/relationship/756/properties/{key}',
                          'self' : 'http://foo/db/data/relationship/756',
                          'properties' : 'http://foo/db/data/relationship/756/properties',
                          'type' : 'TEST_RELATIONSHIP',
                          'extensions' : {
                          },
                          'end' : 'http://foo/db/data/node/789'
                        },'from':'http://foo/db/data/node/761/relationships'}]"
                                      )
                }
            };

            var graphClient = testHarness.CreateAndConnectGraphClient();

            graphClient.Create(
                testNode,
                new TestRelationship(789, testRelationshipPayload));

            testHarness.AssertAllRequestsWereReceived();
        }