Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenMultipleResultsForSingleNode()
        public virtual void ShouldThrowWhenMultipleResultsForSingleNode()
        {
            // given
            GraphDatabaseService graph = DbRule.GraphDatabaseAPI;

            Neo4jMatchers.createIndex(graph, _label1, "name");

            Node node1;
            Node node2;

            using (Transaction tx = graph.BeginTx())
            {
                node1 = graph.CreateNode(_label1);
                node1.SetProperty("name", "Stefan");

                node2 = graph.CreateNode(_label1);
                node2.SetProperty("name", "Stefan");
                tx.Success();
            }

            try
            {
                using (Transaction tx = graph.BeginTx())
                {
                    graph.FindNode(_label1, "name", "Stefan");
                    fail("Expected MultipleFoundException but got none");
                }
            }
            catch (MultipleFoundException e)
            {
                assertThat(e.Message, equalTo(format("Found multiple nodes with label: '%s', property name: 'name' " + "and property value: 'Stefan' while only one was expected.", _label1)));
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createPointPropertyOnLatestDatabase()
        internal virtual void CreatePointPropertyOnLatestDatabase()
        {
            File       storeDir    = _testDirectory.storeDir();
            Label      pointNode   = Label.label("PointNode");
            string     propertyKey = "a";
            PointValue pointValue  = pointValue(Cartesian, 1.0, 2.0);

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(pointNode);
                node.SetProperty(propertyKey, pointValue);
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                assertNotNull(restartedDatabase.FindNode(pointNode, propertyKey, pointValue));
            }
            restartedDatabase.Shutdown();
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createDatePropertyOnLatestDatabase()
        internal virtual void CreateDatePropertyOnLatestDatabase()
        {
            File      storeDir    = _testDirectory.storeDir();
            Label     label       = Label.label("DateNode");
            string    propertyKey = "a";
            LocalDate date        = DateValue.date(1991, 5, 3).asObjectCopy();

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(label);
                node.SetProperty(propertyKey, date);
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                assertNotNull(restartedDatabase.FindNode(label, propertyKey, date));
            }
            restartedDatabase.Shutdown();
        }