public new void ToString() { SqlPredicate p; p = new SqlPredicate("x is null"); p.ToString(); Assert.That(p.ToString(), Is.EqualTo("x IS NULL")); }
public void Clone() { SqlPredicate p; SqlPredicate p1; p = new SqlPredicate("@PH"); p1 = p.Clone(); Assert.That(p.ToString(), Is.EqualTo("@PH")); Assert.That(p1.ToString(), Is.EqualTo("@PH")); p1.Place("PH", "x=1"); Assert.That(p.ToString(), Is.EqualTo("@PH")); Assert.That(p1.ToString(), Is.EqualTo("x=1")); }
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("")); }
public void Place() { SqlPredicate p; p = new SqlPredicate("not c > 1"); p.Place("PH", "a"); Assert.That(p.ToString(), Is.EqualTo("NOT c>1")); p = new SqlPredicate("@PH"); Assert.Throws <CannotBuildASTException>(() => { p.Place("PH", "1"); }); p = new SqlPredicate("@PH"); p.Place("PH", "a=1"); Assert.That(p.ToString(), Is.EqualTo("a=1")); p = new SqlPredicate("Not @PH"); p.Place("PH", "x=2 or y=3"); Assert.That(p.ToString(), Is.EqualTo("NOT (x=2 OR y=3)")); }
public void Place2() { SqlPredicate p; // // Predicate演算子の結合の優先順位が適用前後で変わらないことを確認する // p = new SqlPredicate("@PH"); p.Place("PH", "a=1 and b=2"); Assert.That(p.ToString(), Is.EqualTo("a=1 AND b=2")); p = new SqlPredicate("@PH"); p.Place("PH", "a=1 or b=2"); Assert.That(p.ToString(), Is.EqualTo("a=1 OR b=2")); p = new SqlPredicate("@PH"); p.Place("PH", "not a=1"); Assert.That(p.ToString(), Is.EqualTo("NOT a=1")); p = new SqlPredicate("@PH"); p.Place("PH", "a=1 collate jp"); Assert.That(p.ToString(), Is.EqualTo("a=1 COLLATE jp")); p = new SqlPredicate("@PH AND 1 = 1"); p.Place("PH", "a=1 and b=2"); Assert.That(p.ToString(), Is.EqualTo("a=1 AND b=2 AND 1=1")); p = new SqlPredicate("@PH AND 1 = 1"); p.Place("PH", "a=1 or b=2"); Assert.That(p.ToString(), Is.EqualTo("(a=1 OR b=2) AND 1=1")); p = new SqlPredicate("@PH AND 1 = 1"); p.Place("PH", "not a=1"); Assert.That(p.ToString(), Is.EqualTo("NOT a=1 AND 1=1")); p = new SqlPredicate("@PH AND 1 = 1"); p.Place("PH", "a=1 collate jp"); Assert.That(p.ToString(), Is.EqualTo("a=1 COLLATE jp AND 1=1")); p = new SqlPredicate("@PH OR 1 = 1"); p.Place("PH", "a=1 and b=2"); Assert.That(p.ToString(), Is.EqualTo("a=1 AND b=2 OR 1=1")); p = new SqlPredicate("@PH OR 1 = 1"); p.Place("PH", "a=1 or b=2"); Assert.That(p.ToString(), Is.EqualTo("a=1 OR b=2 OR 1=1")); p = new SqlPredicate("@PH OR 1 = 1"); p.Place("PH", "not a=1"); Assert.That(p.ToString(), Is.EqualTo("NOT a=1 OR 1=1")); p = new SqlPredicate("@PH OR 1 = 1"); p.Place("PH", "a=1 collate jp"); Assert.That(p.ToString(), Is.EqualTo("a=1 COLLATE jp OR 1=1")); p = new SqlPredicate("Not @PH"); p.Place("PH", "a=1 and b=2"); Assert.That(p.ToString(), Is.EqualTo("NOT (a=1 AND b=2)")); p = new SqlPredicate("Not @PH"); p.Place("PH", "a=1 or b=2"); Assert.That(p.ToString(), Is.EqualTo("NOT (a=1 OR b=2)")); p = new SqlPredicate("Not @PH"); p.Place("PH", "not a=1"); Assert.That(p.ToString(), Is.EqualTo("NOT NOT a=1")); p = new SqlPredicate("Not @PH"); p.Place("PH", "a=1 collate jp"); Assert.That(p.ToString(), Is.EqualTo("NOT a=1 COLLATE jp")); p = new SqlPredicate("@PH collate jp"); p.Place("PH", "a=1 and b=2"); Assert.That(p.ToString(), Is.EqualTo("(a=1 AND b=2) COLLATE jp")); p = new SqlPredicate("@PH collate jp"); p.Place("PH", "a=1 or b=2"); Assert.That(p.ToString(), Is.EqualTo("(a=1 OR b=2) COLLATE jp")); p = new SqlPredicate("@PH collate jp"); p.Place("PH", "not a=1"); Assert.That(p.ToString(), Is.EqualTo("NOT a=1 COLLATE jp")); p = new SqlPredicate("@PH collate jp"); p.Place("PH", "a=1 collate jp"); Assert.That(p.ToString(), Is.EqualTo("a=1 COLLATE jp COLLATE jp")); }