1
- using System ;
2
- using System . Collections . Generic ;
3
- using System . Linq ;
4
- using System . Security . Cryptography ;
5
- using System . Text ;
6
- using System . Threading . Tasks ;
7
- using UniGetUI . Core . Data ;
8
- using UniGetUI . Core . Tools ;
1
+ using UniGetUI . Core . Data ;
9
2
10
3
namespace UniGetUI . Core . IconEngine . Tests
11
4
{
@@ -18,19 +11,19 @@ public static class IconCacheEngineTests
18
11
public static async Task TestCacheEngineForSha256 ( string url , byte [ ] data , string managerName , string packageId )
19
12
{
20
13
string extension = url . Split ( "." ) [ ^ 1 ] ;
21
- var expectedFile = Path . Join ( CoreData . UniGetUICacheDirectory_Icons , managerName , packageId + "." + extension ) ;
14
+ string expectedFile = Path . Join ( CoreData . UniGetUICacheDirectory_Icons , managerName , packageId + "." + extension ) ;
22
15
if ( File . Exists ( expectedFile ) ) File . Delete ( expectedFile ) ;
23
16
24
- CacheableIcon icon = new CacheableIcon ( new Uri ( url ) , data ) ;
25
- var path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
17
+ CacheableIcon icon = new ( new Uri ( url ) , data ) ;
18
+ string path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
26
19
Assert . Equal ( expectedFile , path ) ;
27
20
Assert . True ( File . Exists ( path ) ) ;
28
21
29
- var oldModificationDate = File . GetLastWriteTime ( path ) ;
22
+ DateTime oldModificationDate = File . GetLastWriteTime ( path ) ;
30
23
31
24
icon = new CacheableIcon ( new Uri ( url . Replace ( "icon" , "nonexistingicon" ) ) , data ) ;
32
25
path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
33
- var newModificationDate = File . GetLastWriteTime ( path ) ;
26
+ DateTime newModificationDate = File . GetLastWriteTime ( path ) ;
34
27
35
28
Assert . Equal ( oldModificationDate , newModificationDate ) ;
36
29
Assert . Equal ( expectedFile , path ) ;
@@ -42,27 +35,27 @@ public static async Task TestCacheEngineForSha256(string url, byte[] data, strin
42
35
public static async Task TestCacheEngineForPackageVersion ( string url , string version , string managerName , string packageId )
43
36
{
44
37
string extension = url . Split ( "." ) [ ^ 1 ] ;
45
- var expectedFile = Path . Join ( CoreData . UniGetUICacheDirectory_Icons , managerName , packageId + "." + extension ) ;
38
+ string expectedFile = Path . Join ( CoreData . UniGetUICacheDirectory_Icons , managerName , packageId + "." + extension ) ;
46
39
if ( File . Exists ( expectedFile ) ) File . Delete ( expectedFile ) ;
47
40
48
- CacheableIcon icon = new CacheableIcon ( new Uri ( url ) , version ) ;
49
- var path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
41
+ CacheableIcon icon = new ( new Uri ( url ) , version ) ;
42
+ string path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
50
43
Assert . Equal ( expectedFile , path ) ;
51
44
Assert . True ( File . Exists ( path ) ) ;
52
45
53
- var oldModificationDate = File . GetLastWriteTime ( path ) ;
46
+ DateTime oldModificationDate = File . GetLastWriteTime ( path ) ;
54
47
55
48
icon = new CacheableIcon ( new Uri ( url ) , version ) ;
56
49
path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
57
- var newModificationDate = File . GetLastWriteTime ( path ) ;
50
+ DateTime newModificationDate = File . GetLastWriteTime ( path ) ;
58
51
59
52
Assert . Equal ( oldModificationDate , newModificationDate ) ;
60
53
Assert . Equal ( expectedFile , path ) ;
61
54
Assert . True ( File . Exists ( path ) ) ;
62
55
63
56
icon = new CacheableIcon ( new Uri ( url ) , version + "-beta0" ) ;
64
57
path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
65
- var newNewModificationDate = File . GetLastWriteTime ( path ) ;
58
+ DateTime newNewModificationDate = File . GetLastWriteTime ( path ) ;
66
59
67
60
Assert . NotEqual ( oldModificationDate , newNewModificationDate ) ;
68
61
Assert . Equal ( expectedFile , path ) ;
@@ -75,27 +68,27 @@ public static async Task TestCacheEngineForPackageVersion(string url, string ver
75
68
public static async Task TestCacheEngineForPackageSize ( string url , long size , string managerName , string packageId )
76
69
{
77
70
string extension = url . Split ( "." ) [ ^ 1 ] ;
78
- var expectedFile = Path . Join ( CoreData . UniGetUICacheDirectory_Icons , managerName , packageId + "." + extension ) ;
71
+ string expectedFile = Path . Join ( CoreData . UniGetUICacheDirectory_Icons , managerName , packageId + "." + extension ) ;
79
72
if ( File . Exists ( expectedFile ) ) File . Delete ( expectedFile ) ;
80
73
81
- CacheableIcon icon = new CacheableIcon ( new Uri ( url ) , size ) ;
82
- var path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
74
+ CacheableIcon icon = new ( new Uri ( url ) , size ) ;
75
+ string path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
83
76
Assert . Equal ( expectedFile , path ) ;
84
77
Assert . True ( File . Exists ( path ) ) ;
85
78
86
- var oldModificationDate = File . GetLastWriteTime ( path ) ;
79
+ DateTime oldModificationDate = File . GetLastWriteTime ( path ) ;
87
80
88
81
icon = new CacheableIcon ( new Uri ( url ) , size ) ;
89
82
path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
90
- var newModificationDate = File . GetLastWriteTime ( path ) ;
83
+ DateTime newModificationDate = File . GetLastWriteTime ( path ) ;
91
84
92
85
Assert . Equal ( oldModificationDate , newModificationDate ) ;
93
86
Assert . Equal ( expectedFile , path ) ;
94
87
Assert . True ( File . Exists ( path ) ) ;
95
88
96
89
icon = new CacheableIcon ( new Uri ( url ) , size + 1 ) ;
97
90
path = await IconCacheEngine . DownloadIconOrCache ( icon , managerName , packageId ) ;
98
- var newNewModificationDate = File . GetLastWriteTime ( path ) ;
91
+ DateTime newNewModificationDate = File . GetLastWriteTime ( path ) ;
99
92
100
93
Assert . NotEqual ( oldModificationDate , newNewModificationDate ) ;
101
94
Assert . Equal ( expectedFile , path ) ;
0 commit comments