Esempio n. 1
0
        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'" }
            }));
        }
Esempio n. 2
0
        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(""));
        }