Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 212 lines (183 sloc) 6.572 kb
8cbc5ae @markrendle Added DynamicEnumerable with Cast method
authored
1 using System.Collections.Generic;
2 using System.Data.SqlClient;
3 using System.Linq;
ebb68db @markrendle Refactored Mocking.Ado to implement DbX classes instead of ADO interface...
authored
4 using System.Reflection;
bb08cbd @markrendle Changed automated tests to use NUnit
authored
5 using NUnit.Framework;
2ca989e @markrendle Added SQL Server test project
authored
6 using System.IO;
259d286 @markrendle Moved SqlCe35 to separate Provider project
authored
7 using Simple.Data.Ado;
6023b4f @markrendle Moved SQL Server provider to separate assembly
authored
8 using Simple.Data.SqlServer;
e6ea15d @markrendle Fixed FindAllBy(array)
authored
9 using Simple.Data.TestHelper;
2ca989e @markrendle Added SQL Server test project
authored
10
11 namespace Simple.Data.SqlTest
12 {
3c124f0 @markrendle Refactored to AdoAdapterUpserter
authored
13 using System;
14
2ca989e @markrendle Added SQL Server test project
authored
15 /// <summary>
16 /// Summary description for FindTests
17 /// </summary>
bb08cbd @markrendle Changed automated tests to use NUnit
authored
18 [TestFixture]
2ca989e @markrendle Added SQL Server test project
authored
19 public class FindTests
20 {
ffeab05 @markrendle Added DatabaseReset to SQL test project.
authored
21 [TestFixtureSetUp]
22 public void Setup()
23 {
296ef11 @markrendle Added stored procedure creation to database reset
authored
24 DatabaseHelper.Reset();
ffeab05 @markrendle Added DatabaseReset to SQL test project.
authored
25 }
26
bb08cbd @markrendle Changed automated tests to use NUnit
authored
27 [Test]
2ca989e @markrendle Added SQL Server test project
authored
28 public void TestFindById()
29 {
30 var db = DatabaseHelper.Open();
31 var user = db.Users.FindById(1);
32 Assert.AreEqual(1, user.Id);
33 }
34
bb08cbd @markrendle Changed automated tests to use NUnit
authored
35 [Test]
1df75b1 @flq Implementation of UpdateAll with or without condition to update numerous...
flq authored
36 public void TestFindByIdWithCast()
37 {
38 var db = DatabaseHelper.Open();
39 var user = (User)db.Users.FindById(1);
40 Assert.AreEqual(1, user.Id);
41 }
42
43 [Test]
44 public void TestFindByReturnsOne()
45 {
46 var db = DatabaseHelper.Open();
47 var user = (User)db.Users.FindByName("Bob");
48 Assert.AreEqual(1, user.Id);
49 }
50
51 [Test]
8cbc5ae @markrendle Added DynamicEnumerable with Cast method
authored
52 public void TestFindAllByName()
53 {
54 var db = DatabaseHelper.Open();
55 IEnumerable<User> users = db.Users.FindAllByName("Bob").Cast<User>();
56 Assert.AreEqual(1, users.Count());
57 }
58
59 [Test]
aeaa346 @RoyJacobs Where polyfills now correctly handle where...in clause
RoyJacobs authored
60 public void TestFindAllByNameArray()
61 {
62 var db = DatabaseHelper.Open();
63 IEnumerable<User> users = db.Users.FindAllByName(new[] { "Bob", "UnknownUser" }).Cast<User>();
64 Assert.AreEqual(1, users.Count());
65 }
66
67 [Test]
4e5aa12 @markrendle Added tests for fixed issues
authored
68 public void TestFindAllByNameAsIEnumerableOfDynamic()
69 {
70 var db = DatabaseHelper.Open();
71 IEnumerable<dynamic> users = db.Users.FindAllByName("Bob");
72 Assert.AreEqual(1, users.Count());
73 }
74
75 [Test]
7d57f94 @markrendle Release 0.4.4
authored
76 public void TestFindAllByPartialName()
77 {
78 var db = DatabaseHelper.Open();
79 IEnumerable<User> users = db.Users.FindAll(db.Users.Name.Like("Bob")).ToList<User>();
80 Assert.AreEqual(1, users.Count());
81 }
82
83 [Test]
c5c4f00 @markrendle Fixed issue #148
authored
84 public void TestFindAllByPartialNameOnChar()
85 {
86 var db = DatabaseHelper.Open();
87 IEnumerable<User> users = db.UsersWithChar.FindAll(db.UsersWithChar.Name.Like("Bob%")).ToList<User>();
88 Assert.AreEqual(1, users.Count());
89 }
90
91 [Test]
88c23c6 @richardhopton Fix for issue 131; Introduce NotLike into Ado & InMemory Adapters with t...
richardhopton authored
92 public void TestFindAllByExcludedPartialName()
93 {
94 var db = DatabaseHelper.Open();
95 IEnumerable<User> users = db.Users.FindAll(db.Users.Name.NotLike("Bob")).ToList<User>();
96 Assert.AreEqual(2, users.Count());
97 }
98
99 [Test]
2ca989e @markrendle Added SQL Server test project
authored
100 public void TestAllCount()
101 {
102 var db = DatabaseHelper.Open();
ffeab05 @markrendle Added DatabaseReset to SQL test project.
authored
103 var count = db.Users.All().ToList().Count;
2ca989e @markrendle Added SQL Server test project
authored
104 Assert.AreEqual(3, count);
105 }
106
bb08cbd @markrendle Changed automated tests to use NUnit
authored
107 [Test]
416fb9c @markrendle Changed All() to return SimpleQuery
authored
108 public void TestAllWithSkipCount()
109 {
110 var db = DatabaseHelper.Open();
111 var count = db.Users.All().Skip(1).ToList().Count;
112 Assert.AreEqual(2, count);
113 }
114
115 [Test]
2ca989e @markrendle Added SQL Server test project
authored
116 public void TestImplicitCast()
117 {
118 var db = DatabaseHelper.Open();
119 User user = db.Users.FindById(1);
120 Assert.AreEqual(1, user.Id);
121 }
122
bb08cbd @markrendle Changed automated tests to use NUnit
authored
123 [Test]
2ca989e @markrendle Added SQL Server test project
authored
124 public void TestImplicitEnumerableCast()
125 {
126 var db = DatabaseHelper.Open();
3441fa3 @markrendle Completed refactor to allow schema to be specified. TODO: implement sche...
authored
127 foreach (User user in db.Users.All())
2ca989e @markrendle Added SQL Server test project
authored
128 {
129 Assert.IsNotNull(user);
130 }
131 }
132
6e7b5df @markrendle Fixing regressions and refuctoring :(
authored
133
bc0e52c @markrendle Fixed schema-qualification issue in ExpressionFormatter
authored
134 [Test]
135 public void TestFindWithCriteriaAndSchemaQualification()
136 {
137 var db = DatabaseHelper.Open();
138
139 var dboActual = db.dbo.SchemaTable.Find(db.dbo.SchemaTable.Id == 1);
140
068cdbd @markrendle Added ReaderWriterLockSlim to BufferedEnumerable to try and catch heisen...
authored
141 Assert.IsNotNull(dboActual);
bc0e52c @markrendle Fixed schema-qualification issue in ExpressionFormatter
authored
142 Assert.AreEqual("Pass", dboActual.Description);
143 }
0c4e8b0 @flq Added Fix to SchemaProvider to also return column info for views, added ...
flq authored
144
145 [Test]
146 public void TestFindOnAView()
147 {
148 var db = DatabaseHelper.Open();
149 var u = db.VwCustomers.FindByCustomerId(1);
150 Assert.IsNotNull(u);
151 }
9531d32 @markrendle Added Profiling app
authored
152
153 [Test]
154 public void TestCast()
155 {
156 var db = DatabaseHelper.Open();
157 var userQuery = db.Users.All().Cast<User>() as IEnumerable<User>;
158 Assert.IsNotNull(userQuery);
159 var users = userQuery.ToList();
160 Assert.AreNotEqual(0, users.Count);
161 }
b80bf28 @markrendle Use LEFT join on implicitly joined columns in Select lists
authored
162
163 [Test]
164 public void FindByWithNamedParameter()
165 {
166 var db = DatabaseHelper.Open();
167 var user = db.Users.FindBy(Name: "Bob");
168 Assert.IsNotNull(user);
169
170 }
3c124f0 @markrendle Refactored to AdoAdapterUpserter
authored
171
172 [Test]
173 public void WithClauseShouldCastToStaticTypeWithCollection()
174 {
175 var db = DatabaseHelper.Open();
176 Customer actual = db.Customers.WithOrders().FindByCustomerId(1);
177 Assert.IsNotNull(actual);
178 Assert.AreEqual(1, actual.Orders.Single().OrderId);
179 Assert.AreEqual(new DateTime(2010, 10, 10), actual.Orders.Single().OrderDate);
180 }
181
182 [Test]
183 public void NamedParameterAndWithClauseShouldCastToStaticTypeWithCollection()
184 {
185 var db = DatabaseHelper.Open();
186 Customer actual = db.Customers.WithOrders().FindBy(CustomerId: 1);
187 Assert.IsNotNull(actual);
188 Assert.AreEqual(1, actual.Orders.Single().OrderId);
189 Assert.AreEqual(new DateTime(2010, 10, 10), actual.Orders.Single().OrderDate);
190 }
191
192 [Test]
193 public void ExpressionAndWithClauseShouldCastToStaticTypeWithCollection()
194 {
195 var db = DatabaseHelper.Open();
196 Customer actual = db.Customers.WithOrders().Find(db.Customers.CustomerId == 1);
197 Assert.IsNotNull(actual);
198 Assert.AreEqual(1, actual.Orders.Single().OrderId);
199 Assert.AreEqual(new DateTime(2010, 10, 10), actual.Orders.Single().OrderDate);
200 }
28da710 @markrendle Fix for issue #163
authored
201
202 [Test]
203 public void SelectClauseShouldRestrictColumn()
204 {
205 var db = DatabaseHelper.Open();
206 var actual = db.Customers.Select(db.Customers.Name).FindByCustomerId(1).ToScalar();
207 Assert.AreEqual("Test", actual);
208
209 }
2ca989e @markrendle Added SQL Server test project
authored
210 }
211 }
Something went wrong with that request. Please try again.