3
3
using System . IO ;
4
4
using System . Linq ;
5
5
using System . Text . RegularExpressions ;
6
+ using System . Threading . Tasks ;
6
7
using NUnit . Framework ;
7
8
using UnityDataTools . TestCommon ;
8
9
using UnityDataTools . FileSystem ;
@@ -43,19 +44,19 @@ public void Teardown()
43
44
}
44
45
45
46
[ Test ]
46
- public void ArchiveExtract_FilesExtractedSuccessfully (
47
+ public async Task ArchiveExtract_FilesExtractedSuccessfully (
47
48
[ Values ( "" , "-o archive" , "--output-path archive" ) ] string options )
48
49
{
49
50
var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
50
51
51
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "archive" , "extract" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
52
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "archive" , "extract" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
52
53
Assert . IsTrue ( File . Exists ( Path . Combine ( m_TestOutputFolder , "archive" , "CAB-5d40f7cad7c871cf2ad2af19ac542994" ) ) ) ;
53
54
Assert . IsTrue ( File . Exists ( Path . Combine ( m_TestOutputFolder , "archive" , "CAB-5d40f7cad7c871cf2ad2af19ac542994.resS" ) ) ) ;
54
55
Assert . IsTrue ( File . Exists ( Path . Combine ( m_TestOutputFolder , "archive" , "CAB-5d40f7cad7c871cf2ad2af19ac542994.resource" ) ) ) ;
55
56
}
56
57
57
58
[ Test ]
58
- public void ArchiveList_ListFilesCorrectly ( )
59
+ public async Task ArchiveList_ListFilesCorrectly ( )
59
60
{
60
61
var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
61
62
@@ -64,7 +65,7 @@ public void ArchiveList_ListFilesCorrectly()
64
65
var currentOut = Console . Out ;
65
66
Console . SetOut ( sw ) ;
66
67
67
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "archive" , "list" , path } ) ) ;
68
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "archive" , "list" , path } ) ) ;
68
69
69
70
var lines = sw . ToString ( ) . Split ( sw . NewLine ) ;
70
71
@@ -84,13 +85,13 @@ public void ArchiveList_ListFilesCorrectly()
84
85
}
85
86
86
87
[ Test ]
87
- public void DumpText_DefaultArgs_TextFileCreatedCorrectly (
88
+ public async Task DumpText_DefaultArgs_TextFileCreatedCorrectly (
88
89
[ Values ( "" , "-f text" , "--output-format text" ) ] string options )
89
90
{
90
91
var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
91
92
var outputFile = Path . Combine ( m_TestOutputFolder , "CAB-5d40f7cad7c871cf2ad2af19ac542994.txt" ) ;
92
93
93
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
94
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
94
95
Assert . IsTrue ( File . Exists ( outputFile ) ) ;
95
96
96
97
var content = File . ReadAllText ( outputFile ) ;
@@ -104,13 +105,13 @@ public void DumpText_DefaultArgs_TextFileCreatedCorrectly(
104
105
}
105
106
106
107
[ Test ]
107
- public void DumpText_SkipLargeArrays_TextFileCreatedCorrectly (
108
+ public async Task DumpText_SkipLargeArrays_TextFileCreatedCorrectly (
108
109
[ Values ( "-s" , "--skip-large-arrays" ) ] string options )
109
110
{
110
111
var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
111
112
var outputFile = Path . Combine ( m_TestOutputFolder , "CAB-5d40f7cad7c871cf2ad2af19ac542994.txt" ) ;
112
113
113
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
114
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
114
115
Assert . IsTrue ( File . Exists ( outputFile ) ) ;
115
116
116
117
var content = File . ReadAllText ( outputFile ) ;
@@ -124,48 +125,48 @@ public void DumpText_SkipLargeArrays_TextFileCreatedCorrectly(
124
125
}
125
126
126
127
[ Test ]
127
- public void Analyze_DefaultArgs_DatabaseCorrect ( )
128
+ public async Task Analyze_DefaultArgs_DatabaseCorrect ( )
128
129
{
129
130
var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
130
131
var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
131
132
132
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } ) ) ;
133
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } ) ) ;
133
134
134
135
ValidateDatabase ( databasePath , false ) ;
135
136
}
136
137
137
138
[ Test ]
138
- public void Analyze_WithRefs_DatabaseCorrect (
139
+ public async Task Analyze_WithRefs_DatabaseCorrect (
139
140
[ Values ( "-r" , "--extract-references" ) ] string options )
140
141
{
141
142
var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
142
143
var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
143
144
144
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
145
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
145
146
146
147
ValidateDatabase ( databasePath , true ) ;
147
148
}
148
149
149
150
[ Test ]
150
- public void Analyze_WithPattern_DatabaseCorrect (
151
+ public async Task Analyze_WithPattern_DatabaseCorrect (
151
152
[ Values ( "-p *." , "--search-pattern *." ) ] string options )
152
153
{
153
154
var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
154
155
var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
155
156
156
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
157
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
157
158
158
159
ValidateDatabase ( databasePath , false ) ;
159
160
}
160
161
161
162
[ Test ]
162
- public void Analyze_WithPatternNoMatch_DatabaseEmpty (
163
+ public async Task Analyze_WithPatternNoMatch_DatabaseEmpty (
163
164
[ Values ( "-p *.x" , "--search-pattern *.x" ) ] string options )
164
165
{
165
166
var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
166
167
var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
167
168
168
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
169
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
169
170
170
171
using var db = new SQLiteConnection ( $ "Data Source={ databasePath } ;Version=3;New=True;Foreign Keys=False;") ;
171
172
db . Open ( ) ;
@@ -179,13 +180,13 @@ public void Analyze_WithPatternNoMatch_DatabaseEmpty(
179
180
}
180
181
181
182
[ Test ]
182
- public void Analyze_WithOutputFile_DatabaseCorrect (
183
+ public async Task Analyze_WithOutputFile_DatabaseCorrect (
183
184
[ Values ( "-o my_database" , "--output-file my_database" ) ] string options )
184
185
{
185
186
var databasePath = Path . Combine ( m_TestOutputFolder , "my_database" ) ;
186
187
var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
187
188
188
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
189
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
189
190
190
191
ValidateDatabase ( databasePath , false ) ;
191
192
}
@@ -262,12 +263,12 @@ public void Teardown()
262
263
}
263
264
264
265
[ Test ]
265
- public void Analyze_PlayerData_DatabaseCorrect ( )
266
+ public async Task Analyze_PlayerData_DatabaseCorrect ( )
266
267
{
267
268
var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
268
269
var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
269
270
270
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath , "-r" } ) ) ;
271
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath , "-r" } ) ) ;
271
272
272
273
using var db = new SQLiteConnection ( $ "Data Source={ databasePath } ;Version=3;New=True;Foreign Keys=False;") ;
273
274
db . Open ( ) ;
@@ -293,12 +294,12 @@ public void Analyze_PlayerData_DatabaseCorrect()
293
294
}
294
295
295
296
[ Test ]
296
- public void DumpText_PlayerData_TextFileCreatedCorrectly ( )
297
+ public async Task DumpText_PlayerData_TextFileCreatedCorrectly ( )
297
298
{
298
299
var path = Path . Combine ( Context . UnityDataFolder , "level0" ) ;
299
300
var outputFile = Path . Combine ( m_TestOutputFolder , "level0.txt" ) ;
300
301
301
- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "dump" , path } ) ) ;
302
+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "dump" , path } ) ) ;
302
303
Assert . IsTrue ( File . Exists ( outputFile ) ) ;
303
304
304
305
var content = File . ReadAllText ( outputFile ) ;
0 commit comments