public void Place2() { SqlExpr e; // // Expr演算子の結合の優先順位が適用前後で変わらないことを確認する // e = new SqlExpr("@PH"); e.Place("PH", "~a"); Assert.That(e.ToString(), Is.EqualTo("~a")); e = new SqlExpr("@PH"); e.Place("PH", "a+b"); Assert.That(e.ToString(), Is.EqualTo("a+b")); e = new SqlExpr("~@PH"); e.Place("PH", "~a"); Assert.That(e.ToString(), Is.EqualTo("~~a")); e = new SqlExpr("~@PH"); e.Place("PH", "a+b"); Assert.That(e.ToString(), Is.EqualTo("~(a+b)")); e = new SqlExpr("@PH || 'abc'"); e.Place("PH", "~a"); Assert.That(e.ToString(), Is.EqualTo("~a||'abc'")); e = new SqlExpr("@PH || 'abc'"); e.Place("PH", "a+b"); Assert.That(e.ToString(), Is.EqualTo("(a+b)||'abc'")); }
public void HasUnplacedHolders() { SqlExpr e; e = new SqlExpr("@PH"); Assert.That(e.HasUnplacedHolders(), Is.True); e.Place("PH", "'abc'"); Assert.That(e.HasUnplacedHolders(), Is.False); e = new SqlExpr("@PH1 + @PH2"); e.Place("PH1", "+100"); Assert.That(e.HasUnplacedHolders(), Is.True); e.Place("PH2", "-9"); Assert.That(e.HasUnplacedHolders(), Is.False); e = new SqlExpr("@PH || @PH"); e.Place("PH", "'abc'"); Assert.That(e.HasUnplacedHolders(), Is.False); e.Place("PH", "'abc'"); Assert.That(e.HasUnplacedHolders(), Is.False); }
public void GetAllPlaceHolders() { SqlExpr e; e = new SqlExpr("@PH"); Assert.That(e.GetAllPlaceHolders() , Is.EqualTo(new Dictionary <string, string> { { "PH", "" } })); e.Place("PH", "'abc'"); Assert.That(e.GetAllPlaceHolders() , Is.EqualTo(new Dictionary <string, string> { { "PH", "'abc'" } })); e = new SqlExpr("@PH1 + @PH2"); e.Place("PH1", "+100"); Assert.That(e.GetAllPlaceHolders(), Is.EqualTo(new Dictionary <string, string> { { "PH1", "+100" }, { "PH2", "" } })); e.Place("PH2", "-9"); Assert.That(e.GetAllPlaceHolders(), Is.EqualTo(new Dictionary <string, string> { { "PH1", "+100" }, { "PH2", "-9" } })); e = new SqlExpr("@PH || @PH"); e.Place("PH", "'abc'"); Assert.That(e.GetAllPlaceHolders(), Is.EqualTo(new Dictionary <string, string> { { "PH", "'abc'" } })); e.Place("PH", "'abc'"); Assert.That(e.GetAllPlaceHolders(), Is.EqualTo(new Dictionary <string, string> { { "PH", "'abc'" } })); }
public void Empty() { SqlExpr e = new SqlExpr(); Assert.That(e.Clone().ToString(), Is.EqualTo("")); Assert.That(e.GetAllPlaceHolders(), Is.EqualTo(new string[] { })); Assert.That(e.HasUnplacedHolder("T"), Is.False); Assert.That(e.HasUnplacedHolders(), Is.False); Assert.That(e.IsEmpty, Is.True); Assert.That(e.IsPlaceHolderOnly, Is.False); e.Place("PH", "a"); Assert.That(e.ToString(), Is.EqualTo("")); }
public void Place() { SqlExpr e; e = new SqlExpr("DEFAULT"); e.Place("PH", "a"); Assert.That(e.ToString(), Is.EqualTo("DEFAULT")); e = new SqlExpr("@PH"); Assert.Throws <CannotBuildASTException>(() => { e.Place("PH", "a=1"); }); e = new SqlExpr("@PH"); e.Place("PH", "a"); Assert.That(e.ToString(), Is.EqualTo("a")); e = new SqlExpr("cast(@PH as VARCHAR2)"); e.Place("PH", "x"); Assert.That(e.ToString(), Is.EqualTo("CAST(x AS VARCHAR2)")); }