Mercurial > pub > bltoolkit
comparison UnitTests/Linq/ExplicitInterfaceTests.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System; | |
2 using System.Linq; | |
3 | |
4 using BLToolkit.Data.Linq; | |
5 using BLToolkit.DataAccess; | |
6 using BLToolkit.Mapping; | |
7 | |
8 using NUnit.Framework; | |
9 | |
10 namespace Data.Linq | |
11 { | |
12 [TestFixture] | |
13 public class ExplicitInterfaceTests : TestBase | |
14 { | |
15 interface IDate | |
16 { | |
17 DateTime? Date { get; } | |
18 } | |
19 | |
20 interface IDate2 | |
21 { | |
22 DateTime? Date { get; set; } | |
23 } | |
24 | |
25 [TableName("LinqDataTypes")] | |
26 class TestTable : IDate | |
27 { | |
28 [MapField("GuidValue")] | |
29 Guid? GuidValue { get; set; } | |
30 | |
31 [MapField("BoolValue")] | |
32 public bool? Bit { get; set; } | |
33 | |
34 private DateTime? _date; | |
35 | |
36 [MapField("DateTimeValue", Storage = "_date")] | |
37 DateTime? IDate.Date | |
38 { | |
39 get | |
40 { | |
41 return _date; | |
42 } | |
43 } | |
44 } | |
45 | |
46 [TableName("LinqDataTypes")] | |
47 public class TestTable2 : IDate | |
48 { | |
49 [MapField("GuidValue")] | |
50 Guid? GuidValue { get; set; } | |
51 | |
52 [MapField("BoolValue")] | |
53 public bool? Bit { get; set; } | |
54 | |
55 private DateTime? _date; | |
56 | |
57 [MapField("DateTimeValue", Storage = "_date")] | |
58 DateTime? IDate.Date | |
59 { | |
60 get | |
61 { | |
62 return _date; | |
63 } | |
64 } | |
65 } | |
66 | |
67 [TableName("LinqDataTypes")] | |
68 public class TestTable3 : IDate2 | |
69 { | |
70 [MapField("GuidValue")] | |
71 Guid? GuidValue { get; set; } | |
72 | |
73 [MapField("BoolValue")] | |
74 public bool? Bit { get; set; } | |
75 | |
76 [MapField("DateTimeValue")] | |
77 DateTime? IDate2.Date | |
78 { | |
79 get; | |
80 set; | |
81 } | |
82 } | |
83 | |
84 static IQueryable<T> SelectNoDate<T>(IQueryable<T> items) where T : IDate | |
85 { | |
86 return items.Where(i => i.Date == null); | |
87 } | |
88 | |
89 static IQueryable<T> SelectNoDate2<T>(IQueryable<T> items) where T : IDate2 | |
90 { | |
91 return items.Where(i => i.Date == null); | |
92 } | |
93 | |
94 [Test] | |
95 public void ExplicitInterface1() | |
96 { | |
97 using (var db = new TestDbManager()) | |
98 { | |
99 var result = SelectNoDate(db.GetTable<TestTable>()).ToList(); | |
100 } | |
101 } | |
102 | |
103 [Test] | |
104 public void ExplicitInterface2() | |
105 { | |
106 using (var db = new TestDbManager()) | |
107 { | |
108 var result = SelectNoDate(db.GetTable<TestTable2>()).ToList(); | |
109 } | |
110 } | |
111 | |
112 [Test] | |
113 public void ExplicitInterface3() | |
114 { | |
115 using (var db = new TestDbManager()) | |
116 { | |
117 var result = SelectNoDate2(db.GetTable<TestTable3>()).ToList(); | |
118 } | |
119 } | |
120 } | |
121 } |