AIMA.Test.Core.Unit.Logic.FOL.KB.Data.ClauseTest.testSimpleEquals C# (CSharp) Метод

testSimpleEquals() приватный Метод

private testSimpleEquals ( ) : void
Результат void
        public void testSimpleEquals()
        {
            Term cons1 = new Constant("C1");
            Term cons2 = new Constant("C2");
            Term var1 = new Variable("v1");
            List<Term> pts1 = new List<Term>();
            List<Term> pts2 = new List<Term>();
            pts1.Add(cons1);
            pts1.Add(cons2);
            pts1.Add(var1);
            pts2.Add(cons2);
            pts2.Add(cons1);
            pts2.Add(var1);

            Clause c1 = new Clause();
            Clause c2 = new Clause();
            Assert.IsTrue(c1.Equals(c1));
            Assert.IsTrue(c2.Equals(c2));
            Assert.IsTrue(c1.Equals(c2));
            Assert.IsTrue(c2.Equals(c1));

            // Check negatives
            c1.addNegativeLiteral(new Predicate("Pred1", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addNegativeLiteral(new Predicate("Pred1", pts1));
            Assert.IsTrue(c1.Equals(c2));
            Assert.IsTrue(c2.Equals(c1));

            c1.addNegativeLiteral(new Predicate("Pred2", pts2));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addNegativeLiteral(new Predicate("Pred2", pts2));
            Assert.IsTrue(c1.Equals(c2));
            Assert.IsTrue(c2.Equals(c1));
            // Check same but added in different order
            c1.addNegativeLiteral(new Predicate("Pred3", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c1.addNegativeLiteral(new Predicate("Pred4", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addNegativeLiteral(new Predicate("Pred4", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addNegativeLiteral(new Predicate("Pred3", pts1));
            Assert.IsTrue(c1.Equals(c2));
            Assert.IsTrue(c2.Equals(c1));

            // Check positives
            c1.addPositiveLiteral(new Predicate("Pred1", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addPositiveLiteral(new Predicate("Pred1", pts1));
            Assert.IsTrue(c1.Equals(c2));
            Assert.IsTrue(c2.Equals(c1));

            c1.addPositiveLiteral(new Predicate("Pred2", pts2));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addPositiveLiteral(new Predicate("Pred2", pts2));
            Assert.IsTrue(c1.Equals(c2));
            Assert.IsTrue(c2.Equals(c1));
            // Check same but added in different order
            c1.addPositiveLiteral(new Predicate("Pred3", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c1.addPositiveLiteral(new Predicate("Pred4", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addPositiveLiteral(new Predicate("Pred4", pts1));
            Assert.IsFalse(c1.Equals(c2));
            Assert.IsFalse(c2.Equals(c1));
            c2.addPositiveLiteral(new Predicate("Pred3", pts1));
            Assert.IsTrue(c1.Equals(c2));
            Assert.IsTrue(c2.Equals(c1));
        }