/// <summary>Only</summary>
        public virtual void TestNothing()
        {
            IQuery q = NewQuery();

            q.Descend("child");
            SodaTestUtil.Expect(q, _array);
        }
Example #2
0
        public virtual void TestNotIdentity()
        {
            var q = NewQuery();

            q.Constrain(new STStringUTestCase
                            ("aaa"));
            var set = q.Execute();
            var identityConstraint
                = (STStringUTestCase)set.Next
                      ();

            identityConstraint.str = null;
            q = NewQuery();
            q.Constrain(identityConstraint).Identity().Not();
            identityConstraint.str = "aaa";
            SodaTestUtil.Expect(q, new object[]
            {
                new STStringUTestCase
                    (null),
                new STStringUTestCase(
                    "bbb"),
                new STStringUTestCase(
                    "dod")
            });
        }
Example #3
0
        /// <summary>
        /// Magic:
        /// Query for all objects with a known attribute,
        /// independant of the class or even if you don't
        /// know the class.
        /// </summary>
        /// <remarks>
        /// Magic:
        /// Query for all objects with a known attribute,
        /// independant of the class or even if you don't
        /// know the class.
        /// </remarks>
        public virtual void TestUnconstrainedClass()
        {
            IQuery q = NewQuery();

            q.Descend("str").Constrain("aaa");
            SodaTestUtil.Expect(q, new object[] { new Db4objects.Db4o.Tests.Common.Soda.Experiments.STMagicTestCase
                                                      ("aaa"), new STStringTestCase("aaa"), new STStringUTestCase("aaa") });
        }
Example #4
0
        //	public void testRegularExpression() {
        //		Query q = newQuery();
        //		q.constrain(STMagicTestCase.class);
        //		Query qStr = q.descend("str");
        //		final Pattern pattern = Pattern.compile("a*x");
        //		qStr.constrain(new Evaluation() {
        //			public void evaluate(Candidate candidate) {
        //				candidate.include(pattern.matcher(((String) candidate.getObject())).matches());
        //			}
        //		});
        //		com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[1]);
        //	}
        /// <summary>
        /// Magic:
        /// Querying for an implemented Interface.
        /// </summary>
        /// <remarks>
        /// Magic:
        /// Querying for an implemented Interface.
        /// Using an Evaluation allows calls to the interface methods
        /// during the run of the query.s
        /// </remarks>
        public virtual void TestInterface()
        {
            IQuery q = NewQuery();

            q.Constrain(typeof(ISTInterface));
            q.Constrain(new _IEvaluation_117());
            SodaTestUtil.Expect(q, new object[] { new Db4objects.Db4o.Tests.Common.Soda.Experiments.STMagicTestCase
                                                      ("aaa"), new STStringTestCase("aaa") });
        }
Example #5
0
        public virtual void TestEquals()
        {
            IQuery q = NewQuery();

            q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Wrapper.Untyped.STLongWUTestCase
                            (long.MinValue));
            SodaTestUtil.Expect(q, new object[] { new Db4objects.Db4o.Tests.Common.Soda.Wrapper.Untyped.STLongWUTestCase
                                                      (long.MinValue) });
        }
Example #6
0
        public virtual void TestEquals()
        {
            IQuery q = NewQuery();

            q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STLongTestCase(long.MinValue
                                                                                            ));
            SodaTestUtil.Expect(q, new object[] { new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STLongTestCase
                                                      (long.MinValue) });
        }
Example #7
0
        /// <summary>
        /// Magic:
        /// Query for multiple classes.
        /// </summary>
        /// <remarks>
        /// Magic:
        /// Query for multiple classes.
        /// Every class gets it's own slot in the query graph.
        /// </remarks>
        public virtual void TestMultiClass()
        {
            IQuery q = NewQuery();

            q.Constrain(typeof(STDoubleTestCase)).Or(q.Constrain(typeof(STStringTestCase)));
            object[] stDoubles = new STDoubleTestCase().CreateData();
            object[] stStrings = new STStringTestCase().CreateData();
            object[] res       = new object[stDoubles.Length + stStrings.Length];
            System.Array.Copy(stDoubles, 0, res, 0, stDoubles.Length);
            System.Array.Copy(stStrings, 0, res, stDoubles.Length, stStrings.Length);
            SodaTestUtil.Expect(q, res);
        }
Example #8
0
        public virtual void TestNotContains()
        {
            IQuery q = NewQuery();

            q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Wrapper.Untyped.STStringUTestCase
                            ("od"));
            q.Descend("str").Constraints().Contains().Not();
            SodaTestUtil.Expect(q, new object[] { new Db4objects.Db4o.Tests.Common.Soda.Wrapper.Untyped.STStringUTestCase
                                                      (null), new Db4objects.Db4o.Tests.Common.Soda.Wrapper.Untyped.STStringUTestCase(
                                                      "aaa"), new Db4objects.Db4o.Tests.Common.Soda.Wrapper.Untyped.STStringUTestCase(
                                                      "bbb") });
        }
Example #9
0
        /// <summary>
        ///     Magic:
        ///     Query for all objects with a known attribute,
        ///     independant of the class or even if you don't
        ///     know the class.
        /// </summary>
        /// <remarks>
        ///     Magic:
        ///     Query for all objects with a known attribute,
        ///     independant of the class or even if you don't
        ///     know the class.
        /// </remarks>
        public virtual void TestUnconstrainedClass()
        {
            var q = NewQuery();

            q.Descend("str").Constrain("aaa");
            SodaTestUtil.Expect(q, new object[]
            {
                new STMagicTestCase
                    ("aaa"),
                new STStringTestCase("aaa"), new STStringUTestCase("aaa")
            });
        }
Example #10
0
        public virtual void TestEquals()
        {
            var q = NewQuery();

            q.Constrain(new STLongWUTestCase
                            (long.MinValue));
            SodaTestUtil.Expect(q, new object[]
            {
                new STLongWUTestCase
                    (long.MinValue)
            });
        }
Example #11
0
        public virtual void TestNotNull()
        {
            IQuery q = NewQuery();

            q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase
                            (null));
            q.Descend("str").Constrain(null).Not();
            SodaTestUtil.Expect(q, new object[] { new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase
                                                      ("aaa"), new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase("bbb"
                                                                                                                                     ), new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase("dod") }
                                );
        }
Example #12
0
        //	public void testRegularExpression() {
        //		Query q = newQuery();
        //		q.constrain(STMagicTestCase.class);
        //		Query qStr = q.descend("str");
        //		final Pattern pattern = Pattern.compile("a*x");
        //		qStr.constrain(new Evaluation() {
        //			public void evaluate(Candidate candidate) {
        //				candidate.include(pattern.matcher(((String) candidate.getObject())).matches());
        //			}
        //		});
        //		com.db4o.db4ounit.common.soda.util.SodaTestUtil.expectOne(q, _array[1]);
        //	}
        /// <summary>
        ///     Magic:
        ///     Querying for an implemented Interface.
        /// </summary>
        /// <remarks>
        ///     Magic:
        ///     Querying for an implemented Interface.
        ///     Using an Evaluation allows calls to the interface methods
        ///     during the run of the query.s
        /// </remarks>
        public virtual void TestInterface()
        {
            var q = NewQuery();

            q.Constrain(typeof(ISTInterface));
            q.Constrain(new _IEvaluation_117());
            SodaTestUtil.Expect(q, new object[]
            {
                new STMagicTestCase
                    ("aaa"),
                new STStringTestCase("aaa")
            });
        }
Example #13
0
        public virtual void TestNotContains()
        {
            var q = NewQuery();

            q.Constrain(new STStringTestCase
                            ("od"));
            q.Descend("str").Constraints().Contains().Not();
            SodaTestUtil.Expect(q, new object[]
            {
                new STStringTestCase
                    (null),
                new STStringTestCase("aaa"
                                     ),
                new STStringTestCase("bbb")
            }
                                );
        }
Example #14
0
        public virtual void TestNotIdentity()
        {
            IQuery q = NewQuery();

            q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase
                            ("aaa"));
            IObjectSet set = q.Execute();

            Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase identityConstraint
                = (Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase)set.Next();
            identityConstraint.str = null;
            q = NewQuery();
            q.Constrain(identityConstraint).Identity().Not();
            identityConstraint.str = "aaa";
            SodaTestUtil.Expect(q, new object[] { new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase
                                                      (null), new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase("bbb"
                                                                                                                                    ), new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STStringTestCase("dod") }
                                );
        }
Example #15
0
        public virtual void TestNotLike()
        {
            var q = NewQuery();

            q.Constrain(new STStringUTestCase
                            ("aaa"));
            q.Descend("str").Constraints().Like().Not();
            SodaTestUtil.Expect(q, new object[]
            {
                new STStringUTestCase
                    (null),
                new STStringUTestCase(
                    "bbb"),
                new STStringUTestCase(
                    "dod")
            });
            q = NewQuery();
            q.Constrain(new STStringUTestCase
                            ("xxx"));
            q.Descend("str").Constraints().Like();
            Expect(q, new int[] {});
        }