public void ToSqlTextTest01() { SQLWhereTextBuilder target = new SQLWhereTextBuilder(); SQLInTextBuilder inb = new SQLInTextBuilder(); inb.Set("a", "b", "c", "d"); target.Set("abcd", SQLText.CompareOperation.In, System.Data.DbType.String, inb); string expected = "abcd IN ('a','b','c','d')"; string actual; actual = target.ToSqlText(); Assert.AreEqual(expected, actual); }
public void ToSqlTextTest02() { SQLTextBuilder stb = new SQLTextBuilder(); stb.Action = SQLText.Action.Select; stb.Field.Set("field1"); stb.From.Set("DemoTable"); SQLWhereTextBuilder target = new SQLWhereTextBuilder(); SQLInTextBuilder inb = new SQLInTextBuilder(); inb.Set(stb); target.Set("abcd", SQLText.CompareOperation.In, System.Data.DbType.String, inb); string expected = "abcd IN (SELECT field1 FROM DemoTable)"; string actual; actual = target.ToSqlText(); Assert.AreEqual(expected, actual); }
public void ToSqlTextTest02() { string expected = "SELECT CustomerID, CompanyName, ContactTitle, City FROM Customers WHERE CustomerID IN (SELECT CustomerID FROM Orders)"; SQLTextBuilder target = new SQLTextBuilder(); target.Action = SQLText.Action.Select; target.Field.Set("CustomerID", "CompanyName", "ContactTitle", "City"); target.From.Set("Customers"); SQLTextBuilder ta = new SQLTextBuilder(); ta.Action = SQLText.Action.Select; ta.Field.Set("CustomerID"); ta.From.Set("Orders"); SQLInTextBuilder inb = new SQLInTextBuilder(); inb.Set(ta); target.Where.Set("CustomerID", SQLText.CompareOperation.In, DbType.String, inb); Assert.AreEqual(expected, target.ToSqlText()); }