@@ -44,38 +44,42 @@ public DbHelperTest(ITestOutputHelper testOutputHelper)
4444 public ClipboardData GetRandomClipboardData ( )
4545 {
4646 var rand = new Random ( ) ;
47- var data =
48- new ClipboardData ( )
49- {
50- HashId = Utils . GetGuid ( ) ,
51- Text = Utils . RandomString ( 10 ) ,
52- Type = ( CbContentType ) rand . Next ( 3 ) ,
53- Data = Utils . RandomString ( 10 ) ,
54- SenderApp = Utils . RandomString ( 5 ) + ".exe" ,
55- DisplayTitle = Utils . RandomString ( 10 ) ,
56- IconPath = _defaultIconPath ,
57- Icon = new BitmapImage ( new Uri ( _defaultIconPath , UriKind . RelativeOrAbsolute ) ) ,
58- PreviewImagePath = _defaultIconPath ,
59- Score = rand . Next ( 1000 ) ,
60- InitScore = rand . Next ( 1000 ) ,
61- Time = DateTime . Now ,
62- Pined = false ,
63- CreateTime = DateTime . Now ,
64- } ;
47+ var data = new ClipboardData ( )
48+ {
49+ HashId = Utils . GetGuid ( ) ,
50+ Text = Utils . RandomString ( 10 ) ,
51+ Type = ( CbContentType ) rand . Next ( 3 ) ,
52+ Data = Utils . RandomString ( 10 ) ,
53+ SenderApp = Utils . RandomString ( 5 ) + ".exe" ,
54+ DisplayTitle = Utils . RandomString ( 10 ) ,
55+ IconPath = _defaultIconPath ,
56+ Icon = new BitmapImage ( new Uri ( _defaultIconPath , UriKind . RelativeOrAbsolute ) ) ,
57+ PreviewImagePath = _defaultIconPath ,
58+ Score = rand . Next ( 1000 ) ,
59+ InitScore = rand . Next ( 1000 ) ,
60+ Time = DateTime . Now ,
61+ Pined = false ,
62+ CreateTime = DateTime . Now ,
63+ } ;
6564 if ( data . Type == CbContentType . Image )
6665 data . Data = _defaultImage ;
6766 else if ( data . Type == CbContentType . Files )
68- data . Data = new string [ ] { Utils . RandomString ( 10 ) , Utils . RandomString ( 10 ) } ;
67+ data . Data = new string [ ] { Utils . RandomString ( 10 ) , Utils . RandomString ( 10 ) } ;
6968 return data ;
7069 }
7170
7271 [ Fact ]
7372 public void TestCreateDb ( )
7473 {
75- var helper = new DbHelper ( "TestDb" , mode : SqliteOpenMode . Memory , cache : SqliteCacheMode . Shared ) ;
74+ var helper = new DbHelper (
75+ "TestDb" ,
76+ mode : SqliteOpenMode . Memory ,
77+ cache : SqliteCacheMode . Shared
78+ ) ;
7679 _testOutputHelper . WriteLine ( helper . Connection . ConnectionString ) ;
7780 helper . CreateDb ( ) ;
78- var sql = @"SELECT name from sqlite_master WHERE name IN ('record', 'assets') ORDER BY name ASC;" ;
81+ var sql =
82+ @"SELECT name from sqlite_master WHERE name IN ('record', 'assets') ORDER BY name ASC;" ;
7983 var r = helper . Connection . Query ( sql ) . AsList ( ) ;
8084 Assert . True ( r . Count == 2 && r [ 0 ] . name == "assets" && r [ 1 ] . name == "record" ) ;
8185 helper . Close ( ) ;
@@ -86,7 +90,11 @@ public async void TestInsertRecord()
8690 {
8791 // test text
8892 var exampleTextRecord = GetRandomClipboardData ( ) ;
89- var helper = new DbHelper ( "TestDb" , mode : SqliteOpenMode . Memory , cache : SqliteCacheMode . Shared ) ;
93+ var helper = new DbHelper (
94+ "TestDb" ,
95+ mode : SqliteOpenMode . Memory ,
96+ cache : SqliteCacheMode . Shared
97+ ) ;
9098 helper . CreateDb ( ) ;
9199 helper . AddOneRecord ( exampleTextRecord ) ;
92100 var c = ( await helper . GetAllRecord ( ) ) . First ( ) ;
@@ -102,11 +110,18 @@ public async void TestInsertRecord()
102110 [ InlineData ( 2 , "2023-05-28 11:35:00.1+08:00" , 72 ) ]
103111 public async void TestDeleteRecordBefore ( int type , string creatTime , int keepTime )
104112 {
105- var helper = new DbHelper ( "TestDb" , mode : SqliteOpenMode . Memory , cache : SqliteCacheMode . Shared ) ;
113+ var helper = new DbHelper (
114+ "TestDb" ,
115+ mode : SqliteOpenMode . Memory ,
116+ cache : SqliteCacheMode . Shared
117+ ) ;
106118 helper . CreateDb ( ) ;
107119 var now = DateTime . Now ;
108120 var ctime = DateTime . ParseExact (
109- creatTime , "yyyy-MM-dd HH:mm:ss.fzzz" , CultureInfo . CurrentCulture ) ;
121+ creatTime ,
122+ "yyyy-MM-dd HH:mm:ss.fzzz" ,
123+ CultureInfo . CurrentCulture
124+ ) ;
110125 var spans = Enumerable . Range ( 0 , 5000 ) . Skip ( 12 ) . Select ( i => TimeSpan . FromHours ( i ) ) ;
111126 foreach ( var s in spans )
112127 {
@@ -117,9 +132,9 @@ public async void TestDeleteRecordBefore(int type, string creatTime, int keepTim
117132 // helper.Connection.BackupDatabase(new SqliteConnection("Data Source=a.db"));
118133
119134 helper . DeleteRecordByKeepTime ( type , keepTime ) ;
120-
135+
121136 var recordsAfterDelete = await helper . GetAllRecord ( ) ;
122- foreach ( var record in recordsAfterDelete . Where ( r=> r . Type == ( CbContentType ) type ) )
137+ foreach ( var record in recordsAfterDelete . Where ( r => r . Type == ( CbContentType ) type ) )
123138 {
124139 var expTime = record . CreateTime + TimeSpan . FromHours ( keepTime ) ;
125140 if ( expTime < now )
@@ -128,4 +143,4 @@ public async void TestDeleteRecordBefore(int type, string creatTime, int keepTim
128143 }
129144 helper . Close ( ) ;
130145 }
131- }
146+ }
0 commit comments