Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldApplyChangesWithIntermediateConstraintViolations() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldApplyChangesWithIntermediateConstraintViolations()
        {
            // given
            using (Transaction tx = Db.beginTx())
            {
                Db.schema().constraintFor(_foo).assertPropertyIsUnique(BAR).create();
                tx.Success();
            }
            Node fourtyTwo;
            Node fourtyOne;

            using (Transaction tx = Db.beginTx())
            {
                fourtyTwo = Db.createNode(_foo);
                fourtyTwo.SetProperty(BAR, Value1);
                fourtyOne = Db.createNode(_foo);
                fourtyOne.SetProperty(BAR, Value2);
                tx.Success();
            }

            // when
            using (Transaction tx = Db.beginTx())
            {
                fourtyOne.Delete();
                fourtyTwo.SetProperty(BAR, Value2);
                tx.Success();
            }

            // then
            using (Transaction tx = Db.beginTx())
            {
                assertEquals(Value2, fourtyTwo.GetProperty(BAR));
                try
                {
                    fourtyOne.GetProperty(BAR);
                    fail("Should be deleted");
                }
                catch (NotFoundException)
                {
                    // good
                }
                tx.Success();

                assertEquals(fourtyTwo, Db.findNode(_foo, BAR, Value2));
                assertNull(Db.findNode(_foo, BAR, Value1));
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleSizesCloseToTheLimit()
        public virtual void ShouldHandleSizesCloseToTheLimit()
        {
            // given
            CreateIndex(KEY);

            // when
            IDictionary <string, long> strings = new Dictionary <string, long>();

            using (Transaction tx = Db.beginTx())
            {
                for (int i = 0; i < 1_000; i++)
                {
                    string @string;
                    do
                    {
                        @string = Random.nextAlphaNumericString(3_000, 4_000);
                    } while (strings.ContainsKey(@string));

                    Node node = Db.createNode(LABEL);
                    node.SetProperty(KEY, @string);
                    strings[@string] = node.Id;
                }
                tx.Success();
            }

            // then
            using (Transaction tx = Db.beginTx())
            {
                foreach (string @string in strings.Keys)
                {
                    Node node = Db.findNode(LABEL, KEY, @string);
                    assertEquals(strings[@string], node.Id);
                }
                tx.Success();
            }
        }
 private void AssertFindsNamed(Label label, string name)
 {
     using (Transaction tx = Db.beginTx())
     {
         assertNotNull("Must be able to find node created while index was offline", Db.findNode(label, "name", name));
         tx.Success();
     }
 }