Пример #1
0
        public void QueryBaseDuplicatedLabel()
        {
            QueryBase qb = new QueryBase();

            qb.Add(new Query("get spending",
                             new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("spending",
                                                                                   new Variable("customer"),
                                                                                   new Individual("min(5000,EUR)"),
                                                                                   new Individual("previous year")))));
            qb.Add(new Query("get spending",
                             new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("spending",
                                                                                   new Variable("customer"),
                                                                                   new Individual("min(7000,EUR)"),
                                                                                   new Individual("previous year")))));
            Assert.Fail("Should never reach me!");
        }
Пример #2
0
        public void QueryBase()
        {
            QueryBase qb     = new QueryBase();
            Query     query1 = new Query("get spending",
                                         new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("spending",
                                                                                               new Variable("customer"),
                                                                                               new Individual("min(5000,EUR)"),
                                                                                               new Individual("previous year"))));

            qb.Add(query1);
            Assert.AreEqual(1, qb.Count, "(1) QueriesCount");

            Query getQ1 = qb.Get("get spending");

            Assert.AreEqual(query1, getQ1, "Get Query Is Equal");
            Assert.IsTrue(((Atom)query1.AtomGroup.Members[0]).IsIntersecting((Atom)getQ1.AtomGroup.Members[0]), "Get Query Is Similar");

            Assert.IsNull(qb.Get("find me if you can"), "Missing query");

            Query query2 = new Query("get earning",
                                     new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("earning",
                                                                                           new Variable("customer"),
                                                                                           new Individual("min(99999,EUR)"),
                                                                                           new Individual("previous year"))));

            qb.Add(query2);
            Assert.AreEqual(2, qb.Count, "(2) QueriesCount");

            qb.Remove(qb.Get(0));
            Assert.AreEqual(1, qb.Count, "(3) QueriesCount");
            Query getQ2 = qb.Get(0);

            Assert.AreEqual(query2, getQ2, "(3) Get Query Is Equal");
            Assert.IsTrue(((Atom)query2.AtomGroup.Members[0]).IsIntersecting((Atom)getQ2.AtomGroup.Members[0]), "(3) Get Query Is Similar");

            qb.Add(new Query("to be killed",
                             new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("victim",
                                                                                   new Variable("test"),
                                                                                   new Individual("whatsoever")))));
            Assert.AreEqual(2, qb.Count, "(4) QueriesCount");

            qb.Remove(qb.Get("to be killed"));
            Assert.AreEqual(1, qb.Count, "(5) QueriesCount");

            qb.Remove(query2);
            Assert.AreEqual(0, qb.Count, "(6) QueriesCount");
        }
Пример #3
0
 public void QueryBaseIndexTooHigh()
 {
     Assert.Throws <IndexOutOfRangeException>(() => {
         QueryBase qb = new QueryBase();
         qb.Add(new Query(
                    "get spending",
                    new AtomGroup(
                        AtomGroup.LogicalOperator.And,
                        new Atom("spending",
                                 new Variable("customer"),
                                 new Individual("min(5000,EUR)"),
                                 new Individual("previous year")))));
         qb.Get(2);
         Assert.Fail("Should never reach me!");
     });
 }
Пример #4
0
 public void QueryBaseIndexTooHigh()
 {
     QueryBase qb = new QueryBase();
     qb.Add(new Query("get spending",
                           new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("spending",
                                               new Variable("customer"),
                                               new Individual("min(5000,EUR)"),
                                               new Individual("previous year")))));
     qb.Get(2);
     Assert.Fail("Should never reach me!");
 }
Пример #5
0
        public void QueryBase()
        {
            QueryBase qb = new QueryBase();
            Query query1 = new Query("get spending",
                                          new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("spending",
                                                              new Variable("customer"),
                                                              new Individual("min(5000,EUR)"),
                                                              new Individual("previous year"))));
            qb.Add(query1);
            Assert.AreEqual(1, qb.Count, "(1) QueriesCount");

            Query getQ1 = qb.Get("get spending");
            Assert.AreEqual(query1, getQ1, "Get Query Is Equal");
            Assert.IsTrue(((Atom)query1.AtomGroup.Members[0]).IsIntersecting((Atom)getQ1.AtomGroup.Members[0]), "Get Query Is Similar");

            Assert.IsNull(qb.Get("find me if you can"), "Missing query");

            Query query2 = new Query("get earning",
                                          new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("earning",
                                                              new Variable("customer"),
                                                              new Individual("min(99999,EUR)"),
                                                              new Individual("previous year"))));
            qb.Add(query2);
            Assert.AreEqual(2, qb.Count, "(2) QueriesCount");

            qb.Remove(qb.Get(0));
            Assert.AreEqual(1, qb.Count, "(3) QueriesCount");
            Query getQ2 = qb.Get(0);
            Assert.AreEqual(query2, getQ2, "(3) Get Query Is Equal");
            Assert.IsTrue(((Atom)query2.AtomGroup.Members[0]).IsIntersecting((Atom)getQ2.AtomGroup.Members[0]), "(3) Get Query Is Similar");

            qb.Add(new Query("to be killed",
                                  new AtomGroup(AtomGroup.LogicalOperator.And, new Atom("victim",
                                                      new Variable("test"),
                                                      new Individual("whatsoever")))));
            Assert.AreEqual(2, qb.Count, "(4) QueriesCount");

            qb.Remove(qb.Get("to be killed"));
            Assert.AreEqual(1, qb.Count, "(5) QueriesCount");

            qb.Remove(query2);
            Assert.AreEqual(0, qb.Count, "(6) QueriesCount");
        }