コード例 #1
0
        public void TestUpdate_singleValue_moreThanOneRow()
        {
            CreateTestDatabase();
            query = new QueryWrapper(connectionString);

            query.InsertQuery(testDBName, "Name, Gender, Salary", "'Bob', NULL, '80'");
            query.InsertQuery(testDBName, "Name, Gender, Salary", "'Tom', NULL, '84'");
            query.InsertQuery(testDBName, "Name, Gender, Salary", "'Teresa', NULL, '100'");
            DataTable table = query.SelectQuery("*", testDBName);

            query.UpdateQuery(testDBName, "Salary", "120", "2");

            table = query.SelectQuery("*", testDBName);

            Assert.AreEqual(3, table.Rows.Count);
            Assert.AreEqual("Tom", table.Rows[1]["Name"].ToString());
            Assert.AreEqual("", table.Rows[1]["Gender"].ToString());
            Assert.AreEqual("120", table.Rows[1]["Salary"].ToString());
        }
コード例 #2
0
        public void TestUpdate_singleValue()
        {
            CreateTestDatabase();
            query = new QueryWrapper(connectionString);

            query.InsertQuery(testDBName, "Name, Gender, Salary", "'Bob', NULL, '80'");
            DataTable table = query.SelectQuery("*", testDBName);

            query.UpdateQuery(testDBName, "Salary", "120", "1");

            table = query.SelectQuery("*", testDBName);

            Assert.AreEqual(1, table.Rows.Count);
            Assert.AreEqual("Bob", table.Rows[0]["Name"].ToString());
            Assert.AreEqual("", table.Rows[0]["Gender"].ToString());
            Assert.AreEqual("120", table.Rows[0]["Salary"].ToString());
        }