1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
3
using NUnit . Framework ;
4
+ using SQLite . Net . Attributes ;
4
5
5
6
namespace SQLite . Net . Tests
6
7
{
7
- [ TestFixture ]
8
- public class UnicodeTest
9
- {
10
- [ Test ]
11
- public void Insert ( )
12
- {
13
- var db = new TestDb ( ) ;
8
+ [ TestFixture ]
9
+ public class UnicodeTest
10
+ {
11
+ [ Table ( "\u7523 \u54C1 " ) ]
12
+ public class UnicodeProduct
13
+ {
14
+ [ AutoIncrement , PrimaryKey , Column ( "\u6A19 \u8B58 " ) ]
15
+ public int Id { get ; set ; }
14
16
15
- db . CreateTable < Product > ( ) ;
17
+ [ Column ( "\u540D " ) ]
18
+ public string Name { get ; set ; }
16
19
17
- string testString = "\u2329 \u221E \u232A " ;
20
+ [ Column ( "\u5024 " ) ]
21
+ public decimal Price { get ; set ; }
18
22
19
- db . Insert ( new Product
20
- {
21
- Name = testString ,
22
- } ) ;
23
+ [ Column ( "\u53CE \u76CA " ) ]
24
+ public uint TotalSales { get ; set ; }
25
+ }
23
26
24
- var p = db . Get < Product > ( 1 ) ;
27
+ [ Test ]
28
+ public void Insert ( )
29
+ {
30
+ var db = new TestDb ( ) ;
25
31
26
- Assert . AreEqual ( testString , p . Name ) ;
27
- }
32
+ db . CreateTable < UnicodeProduct > ( ) ;
28
33
29
- [ Test ]
30
- public void Query ( )
31
- {
32
- var db = new TestDb ( ) ;
34
+ string testString = "\u2329 \u221E \u232A " ;
33
35
34
- db . CreateTable < Product > ( ) ;
36
+ db . Insert ( new UnicodeProduct
37
+ {
38
+ Name = testString ,
39
+ } ) ;
35
40
36
- string testString = " \u2329 \u221E \u232A " ;
41
+ var p = db . Get < UnicodeProduct > ( 1 ) ;
37
42
38
- db . Insert ( new Product
39
- {
40
- Name = testString ,
41
- } ) ;
43
+ Assert . AreEqual ( testString , p . Name ) ;
44
+ }
42
45
43
- List < Product > ps = ( from p in db . Table < Product > ( ) where p . Name == testString select p ) . ToList ( ) ;
46
+ [ Test ]
47
+ public void Query ( )
48
+ {
49
+ var db = new TestDb ( ) ;
44
50
45
- Assert . AreEqual ( 1 , ps . Count ) ;
46
- Assert . AreEqual ( testString , ps [ 0 ] . Name ) ;
47
- }
48
- }
51
+ db . CreateTable < UnicodeProduct > ( ) ;
52
+
53
+ string testString = "\u2329 \u221E \u232A " ;
54
+
55
+ db . Insert ( new UnicodeProduct
56
+ {
57
+ Name = testString ,
58
+ } ) ;
59
+
60
+ var ps = ( from p in db . Table < UnicodeProduct > ( ) where p . Name == testString select p ) . ToList ( ) ;
61
+
62
+ Assert . AreEqual ( 1 , ps . Count ) ;
63
+ Assert . AreEqual ( testString , ps [ 0 ] . Name ) ;
64
+ }
65
+ }
49
66
}
0 commit comments