예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNotInTransactionException()
        public virtual void TestNotInTransactionException()
        {
            Node node1 = _graph.createNode();

            node1.SetProperty("test", 1);
            Node         node2 = _graph.createNode();
            Node         node3 = _graph.createNode();
            Relationship rel   = node1.CreateRelationshipTo(node2, MyRelTypes.TEST);

            rel.SetProperty("test", 11);
            Commit();
            try
            {
                _graph.createNode();
                fail("Create node with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node1.CreateRelationshipTo(node2, MyRelTypes.TEST);
                fail("Create relationship with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node1.SetProperty("test", 2);
                fail("Set property with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                rel.SetProperty("test", 22);
                fail("Set property with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node3.Delete();
                fail("Delete node with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                rel.Delete();
                fail("Delete relationship with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            NewTransaction();
            assertEquals(node1.GetProperty("test"), 1);
            assertEquals(rel.GetProperty("test"), 11);
            assertEquals(rel, node1.GetSingleRelationship(MyRelTypes.TEST, Direction.OUTGOING));
            node1.Delete();
            node2.Delete();
            rel.Delete();
            node3.Delete();

            // Finally
            Rollback();
        }