0
|
1 using System;
|
|
2 using NUnit.Framework;
|
|
3 using BLToolkit.Data.Sql;
|
|
4
|
|
5 namespace Data.Sql
|
|
6 {
|
|
7 [TestFixture]
|
|
8 public class SelectTest
|
|
9 {
|
|
10 public static SqlTable Order = new SqlTable
|
|
11 {
|
|
12 Name = "Order",
|
|
13 Fields = { new SqlField { Name = "ID" }, new SqlField { Name = "Number" } }
|
|
14 };
|
|
15
|
|
16 [Test]
|
|
17 public void Test1()
|
|
18 {
|
|
19 var sb = new SqlQuery();
|
|
20
|
|
21 sb
|
|
22 .Select
|
|
23 .Field(Order["ID"])
|
|
24 .Field(Order["Number"])
|
|
25 ;
|
|
26
|
|
27 Assert.AreEqual(2, sb.Select.Columns.Count);
|
|
28 }
|
|
29
|
|
30 [Test]
|
|
31 public void Test2()
|
|
32 {
|
|
33 var sb = new SqlQuery();
|
|
34
|
|
35 sb
|
|
36 .Select
|
|
37 .Field(Order["ID"])
|
|
38 .Field(Order["Number"])
|
|
39 .Field(Order["ID"])
|
|
40 ;
|
|
41
|
|
42 Assert.AreEqual(2, sb.Select.Columns.Count);
|
|
43 }
|
|
44
|
|
45 [Test]
|
|
46 public void Test3()
|
|
47 {
|
|
48 var sb = new SqlQuery();
|
|
49
|
|
50 sb
|
|
51 .Select
|
|
52 .Field(Order["ID"], "id1")
|
|
53 .Field(Order["ID"])
|
|
54 .Expr("{0} + {1}", Order["Number"], Order["Number"])
|
|
55 .Expr(new SqlExpression("{0} + {1}", Order["Number"], Order["Number"]))
|
|
56 ;
|
|
57
|
|
58 Assert.AreEqual(2, sb.Select.Columns.Count);
|
|
59 }
|
|
60 }
|
|
61 }
|