Beispiel #1
0
        public void Empty()
        {
            SqlPredicate p = new SqlPredicate();

            Assert.That(p.And(p).ToString(), Is.EqualTo(""));
            Assert.That(p.Clone().ToString(), Is.EqualTo(""));
            Assert.That(p.GetAllPlaceHolders(), Is.EqualTo(new string[] { }));
            Assert.That(p.HasUnplacedHolder("T"), Is.False);
            Assert.That(p.HasUnplacedHolders(), Is.False);
            Assert.That(p.IsEmpty, Is.True);
            Assert.That(p.IsPlaceHolderOnly, Is.False);
            p.Place("PH", "a=1");
            Assert.That(p.ToString(), Is.EqualTo(""));
        }
Beispiel #2
0
        public void And()
        {
            SqlPredicate p;
            SqlPredicate p1;

            p  = new SqlPredicate("@PH and 1 = 1");
            p1 = p.And(new SqlPredicate("x is null and 2=2"));
            Assert.That(p1.ToString(), Is.EqualTo("@PH AND 1=1 AND x IS NULL AND 2=2"));

            p1 = p.And(new SqlPredicate("x is null or 2=2"));
            Assert.That(p1.ToString(), Is.EqualTo("@PH AND 1=1 AND (x IS NULL OR 2=2)"));

            p  = new SqlPredicate("@PH or 1 = 1");
            p1 = p.And(new SqlPredicate("x is null and 2 = 2"));
            Assert.That(p1.ToString(), Is.EqualTo("(@PH OR 1=1) AND x IS NULL AND 2=2"));

            p  = new SqlPredicate("x is null");
            p1 = p.And(p);
            Assert.That(p1.ToString(), Is.EqualTo("x IS NULL AND x IS NULL"));

            p  = new SqlPredicate("x = 11");
            p1 = p.And(new SqlPredicate());
            Assert.That(p1.ToString(), Is.EqualTo("x=11"));
        }