1+ using System . Collections . Generic ;
2+ using System . Collections . ObjectModel ;
3+ using System . Linq ;
4+ using NUnit . Framework ;
5+
6+ namespace Simple . Data . InMemoryTest
7+ {
8+ [ TestFixture ]
9+ public class SimpleQueryConversionTests
10+ {
11+ [ Test ]
12+ public void ShouldCastToList ( )
13+ {
14+ Database . UseMockAdapter ( new InMemoryAdapter ( ) ) ;
15+ var db = Database . Open ( ) ;
16+ db . Test . Insert ( Id : 1 , Name : "Alice" ) ;
17+ db . Test . Insert ( Id : 2 , Name : "Bob" ) ;
18+ List < Person > records = db . Test . All ( ) ;
19+ Assert . IsNotNull ( records ) ;
20+ Assert . AreEqual ( 2 , records . Count ) ;
21+ }
22+
23+ [ Test ]
24+ public void ShouldCastToPersonCollection ( )
25+ {
26+ Database . UseMockAdapter ( new InMemoryAdapter ( ) ) ;
27+ var db = Database . Open ( ) ;
28+ db . Test . Insert ( Id : 1 , Name : "Alice" ) ;
29+ db . Test . Insert ( Id : 2 , Name : "Bob" ) ;
30+ PersonCollection records = db . Test . All ( ) ;
31+ Assert . IsNotNull ( records ) ;
32+ Assert . AreEqual ( 2 , records . Count ) ;
33+ }
34+
35+ [ Test ]
36+ public void ShouldCastToIEnumerableOfPerson ( )
37+ {
38+ Database . UseMockAdapter ( new InMemoryAdapter ( ) ) ;
39+ var db = Database . Open ( ) ;
40+ db . Test . Insert ( Id : 1 , Name : "Alice" ) ;
41+ db . Test . Insert ( Id : 2 , Name : "Bob" ) ;
42+ IEnumerable < Person > records = db . Test . All ( ) ;
43+ Assert . IsNotNull ( records ) ;
44+ Assert . AreEqual ( 2 , records . Count ( ) ) ;
45+ }
46+ }
47+
48+ public class Person
49+ {
50+ public int Id { get ; set ; }
51+ public string Name { get ; set ; }
52+ }
53+
54+ public class PersonCollection : Collection < Person >
55+ {
56+
57+ }
58+ }
0 commit comments