public void TestUpdateQueryBuilder3() { string tbl = @"TableName"; string exp = @"INSERT INTO TableName (COLUMN1,COLUMN2) VALUES (@__param_0,@__param_1)"; UpdateQueryBuilder b = new UpdateQueryBuilder(tbl); UpdatePabo pabo = new UpdatePabo(); b.SetParams(ObjectQuery.GetParams(pabo)); using (SqlConnection conn = new SqlConnection()) using (DbCommand result = b.Result(conn, UpdateType.INSERT)) { Assert.AreEqual(exp, result.CommandText); Assert.AreEqual(pabo.Num, result.Parameters[0].Value); Assert.AreEqual(pabo.S, result.Parameters[1].Value); } }
public void TestUpdateQueryBuilder4() { object[] whereParam = { 2, @"DEF" }; string where = @"COLUMN3=? AND COLUMN4=?"; string tbl = @"TableName"; string exp = @"UPDATE TableName SET COLUMN1=@__param_0,COLUMN2=@__param_1 WHERE COLUMN3=@__param_2 AND COLUMN4=@__param_3"; UpdateQueryBuilder b = new UpdateQueryBuilder(tbl); UpdatePabo pabo = new UpdatePabo(); b.SetParams(ObjectQuery.GetParams(pabo)); b.SetWhere(where, whereParam); using (SqlConnection conn = new SqlConnection()) using (DbCommand result = b.Result(conn, UpdateType.UPDATE)) { Assert.AreEqual(exp, result.CommandText); Assert.AreEqual(1, result.Parameters[0].Value); Assert.AreEqual(@"ABC", result.Parameters[1].Value); Assert.AreEqual(2, result.Parameters[2].Value); Assert.AreEqual(@"DEF", result.Parameters[3].Value); } }