public void CreateNode__CreatesNode()
        {
            var mock = InitializeMockWebClient(AutoCommitAddress);

            var session = new CypherSession(BaseUri, mock.Object);
            var node = session.CreateNode(new {name = Name}, "person");
            Assert.AreEqual(node.AsDynamic().person, Name);
            Assert.AreEqual((node).Labels.First(), "person");
        }
예제 #2
0
        public void CreateNode__CreatesNode()
        {
            var mock = InitializeMockWebClient(AutoCommitAddress);

            var session = new CypherSession(BaseUri, mock.Object);
            var node    = session.CreateNode(new { name = Name }, "person");

            Assert.AreEqual(node.AsDynamic().person, Name);
            Assert.AreEqual((node).Labels.First(), "person");
        }
예제 #3
0
        public void CreateNode_WithinRollbackTransaction_CallsRollback()
        {
            var mock = InitializeMockWebClient(BeginTransactionUri);

            //Rollback
            mock.Setup(m => m.DeleteAsync(KeepAliveAddress)).Returns(() => BuildResponse(EmptyResponse));

            var session = new CypherSession(BaseUri, mock.Object);

            using (new TransactionScope())
            {
                session.CreateNode(new { name = Name }, "person");
            }

            mock.Verify(m => m.DeleteAsync(KeepAliveAddress));
        }
        public void CreateNode_WithinRollbackTransaction_CallsRollback()
        {
            var mock = InitializeMockWebClient(BeginTransactionUri);

            //Rollback
            mock.Setup(m => m.DeleteAsync(KeepAliveAddress)).Returns(() => BuildResponse(EmptyResponse));

            var session = new CypherSession(BaseUri, mock.Object);

            using (new TransactionScope())
            {
                session.CreateNode(new { name = Name }, "person");
            }

            mock.Verify(m => m.DeleteAsync(KeepAliveAddress));
        }
        public void CreateNode_WithinCommitedTransaction_CallsCommit()
        {
            var mock = InitializeMockWebClient(BeginTransactionUri);

            //Keep alive.
            mock.Setup(m => m.PostAsync(KeepAliveAddress, EmptyRequest))
                .Returns(() => BuildResponse(@"{""commit"":""" + CommitAddress + @""",""results"":[],""transaction"":{""expires"":""Wed, 02 Oct 2013 15:18:27 +0000""},""errors"":[]}"));

            //Commit
            mock.Setup(m => m.PostAsync(CommitAddress, EmptyRequest)).Returns(() => BuildResponse(EmptyResponse));

            var session = new CypherSession(BaseUri, mock.Object);
            using (var ts = new TransactionScope())
            {
                session.CreateNode(new {name = Name}, "person");
                ts.Complete();
            }

            mock.Verify(m => m.PostAsync(KeepAliveAddress, EmptyRequest));
            mock.Verify(m => m.PostAsync(CommitAddress, EmptyRequest));
        }
예제 #6
0
        public void CreateNode_WithinCommitedTransaction_CallsCommit()
        {
            var mock = InitializeMockWebClient(BeginTransactionUri);

            //Keep alive.
            mock.Setup(m => m.PostAsync(KeepAliveAddress, EmptyRequest))
            .Returns(() => BuildResponse(@"{""commit"":""" + CommitAddress + @""",""results"":[],""transaction"":{""expires"":""Wed, 02 Oct 2013 15:18:27 +0000""},""errors"":[]}"));

            //Commit
            mock.Setup(m => m.PostAsync(CommitAddress, EmptyRequest)).Returns(() => BuildResponse(EmptyResponse));

            var session = new CypherSession(BaseUri, mock.Object);

            using (var ts = new TransactionScope())
            {
                session.CreateNode(new { name = Name }, "person");
                ts.Complete();
            }

            mock.Verify(m => m.PostAsync(KeepAliveAddress, EmptyRequest));
            mock.Verify(m => m.PostAsync(CommitAddress, EmptyRequest));
        }