Azavea.Open.DAO.Tests.SqlUtilTests.TestMakeUpdateStatement C# (CSharp) Method

TestMakeUpdateStatement() private method

private TestMakeUpdateStatement ( ) : void
return void
        public void TestMakeUpdateStatement()
        {
            Dictionary<string, object> cols = new Dictionary<string, object>();
            List<object> parms = new List<object>();
            cols["test"] = 5;
            string update = SqlUtilities.MakeUpdateStatement("Table", null, cols, parms);
            Assert.AreEqual("UPDATE Table SET test = ?", update, "Didn't work with update to 5.");
            Assert.AreEqual(1, parms.Count, "Wrong number of sql parameters generated for just update.");
            Assert.AreEqual(5, parms[0], "Wrong sql parameter value generated for just update.");

            parms = new List<object>();
            Dictionary<string, object> wheres = new Dictionary<string, object>();
            wheres["blah"] = "four";
            update = SqlUtilities.MakeUpdateStatement("Table", wheres, cols, parms);
            Assert.AreEqual("UPDATE Table SET test = ? WHERE blah = ?", update,
                "Didn't work with update with where.");
            Assert.AreEqual(2, parms.Count, "Wrong number of sql parameters generated for update with where.");
            Assert.AreEqual(5, parms[0], "Wrong first sql parameter value generated for update with where.");
            Assert.AreEqual("four", parms[1], "Wrong second sql parameter value generated for update with where.");
        }