33using System . IO ;
44using System . Linq ;
55using System . Text . RegularExpressions ;
6+ using System . Threading . Tasks ;
67using NUnit . Framework ;
78using UnityDataTools . TestCommon ;
89using UnityDataTools . FileSystem ;
@@ -44,19 +45,32 @@ public void Teardown()
4445 }
4546
4647 [ Test ]
47- public void ArchiveExtract_FilesExtractedSuccessfully (
48+ public async Task InvalidFile (
49+ [ Values (
50+ new string [ ] { "archive" , "extract" } ,
51+ new string [ ] { "archive" , "list" } ,
52+ new string [ ] { "dump" }
53+ ) ] string [ ] args )
54+ {
55+ var path = Path . Combine ( Context . TestDataFolder , "invalidfile" ) ;
56+ var command = args . Append ( path ) ;
57+ Assert . AreNotEqual ( 0 , await Program . Main ( command . ToArray ( ) ) ) ;
58+ }
59+
60+ [ Test ]
61+ public async Task ArchiveExtract_FilesExtractedSuccessfully (
4862 [ Values ( "" , "-o archive" , "--output-path archive" ) ] string options )
4963 {
5064 var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
5165
52- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "archive" , "extract" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
66+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "archive" , "extract" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
5367 Assert . IsTrue ( File . Exists ( Path . Combine ( m_TestOutputFolder , "archive" , "CAB-5d40f7cad7c871cf2ad2af19ac542994" ) ) ) ;
5468 Assert . IsTrue ( File . Exists ( Path . Combine ( m_TestOutputFolder , "archive" , "CAB-5d40f7cad7c871cf2ad2af19ac542994.resS" ) ) ) ;
5569 Assert . IsTrue ( File . Exists ( Path . Combine ( m_TestOutputFolder , "archive" , "CAB-5d40f7cad7c871cf2ad2af19ac542994.resource" ) ) ) ;
5670 }
5771
5872 [ Test ]
59- public void ArchiveList_ListFilesCorrectly ( )
73+ public async Task ArchiveList_ListFilesCorrectly ( )
6074 {
6175 var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
6276
@@ -65,7 +79,7 @@ public void ArchiveList_ListFilesCorrectly()
6579 var currentOut = Console . Out ;
6680 Console . SetOut ( sw ) ;
6781
68- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "archive" , "list" , path } ) ) ;
82+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "archive" , "list" , path } ) ) ;
6983
7084 var lines = sw . ToString ( ) . Split ( sw . NewLine ) ;
7185
@@ -85,13 +99,13 @@ public void ArchiveList_ListFilesCorrectly()
8599 }
86100
87101 [ Test ]
88- public void DumpText_DefaultArgs_TextFileCreatedCorrectly (
102+ public async Task DumpText_DefaultArgs_TextFileCreatedCorrectly (
89103 [ Values ( "" , "-f text" , "--output-format text" ) ] string options )
90104 {
91105 var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
92106 var outputFile = Path . Combine ( m_TestOutputFolder , "CAB-5d40f7cad7c871cf2ad2af19ac542994.txt" ) ;
93107
94- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
108+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
95109 Assert . IsTrue ( File . Exists ( outputFile ) ) ;
96110
97111 var content = File . ReadAllText ( outputFile ) ;
@@ -105,13 +119,13 @@ public void DumpText_DefaultArgs_TextFileCreatedCorrectly(
105119 }
106120
107121 [ Test ]
108- public void DumpText_SkipLargeArrays_TextFileCreatedCorrectly (
122+ public async Task DumpText_SkipLargeArrays_TextFileCreatedCorrectly (
109123 [ Values ( "-s" , "--skip-large-arrays" ) ] string options )
110124 {
111125 var path = Path . Combine ( Context . UnityDataFolder , "assetbundle" ) ;
112126 var outputFile = Path . Combine ( m_TestOutputFolder , "CAB-5d40f7cad7c871cf2ad2af19ac542994.txt" ) ;
113127
114- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
128+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "dump" , path } . Concat ( options . Split ( " " , StringSplitOptions . RemoveEmptyEntries ) ) . ToArray ( ) ) ) ;
115129 Assert . IsTrue ( File . Exists ( outputFile ) ) ;
116130
117131 var content = File . ReadAllText ( outputFile ) ;
@@ -125,48 +139,48 @@ public void DumpText_SkipLargeArrays_TextFileCreatedCorrectly(
125139 }
126140
127141 [ Test ]
128- public void Analyze_DefaultArgs_DatabaseCorrect ( )
142+ public async Task Analyze_DefaultArgs_DatabaseCorrect ( )
129143 {
130144 var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
131145 var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
132146
133- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } ) ) ;
147+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } ) ) ;
134148
135149 ValidateDatabase ( databasePath , false ) ;
136150 }
137151
138152 [ Test ]
139- public void Analyze_WithRefs_DatabaseCorrect (
153+ public async Task Analyze_WithRefs_DatabaseCorrect (
140154 [ Values ( "-r" , "--extract-references" ) ] string options )
141155 {
142156 var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
143157 var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
144158
145- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
159+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
146160
147161 ValidateDatabase ( databasePath , true ) ;
148162 }
149163
150164 [ Test ]
151- public void Analyze_WithPattern_DatabaseCorrect (
165+ public async Task Analyze_WithPattern_DatabaseCorrect (
152166 [ Values ( "-p *." , "--search-pattern *." ) ] string options )
153167 {
154168 var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
155169 var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
156170
157- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
171+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
158172
159173 ValidateDatabase ( databasePath , false ) ;
160174 }
161175
162176 [ Test ]
163- public void Analyze_WithPatternNoMatch_DatabaseEmpty (
177+ public async Task Analyze_WithPatternNoMatch_DatabaseEmpty (
164178 [ Values ( "-p *.x" , "--search-pattern *.x" ) ] string options )
165179 {
166180 var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
167181 var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
168182
169- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
183+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
170184
171185 using var db = new SQLiteConnection ( $ "Data Source={ databasePath } ;Version=3;New=True;Foreign Keys=False;") ;
172186 db . Open ( ) ;
@@ -180,13 +194,13 @@ public void Analyze_WithPatternNoMatch_DatabaseEmpty(
180194 }
181195
182196 [ Test ]
183- public void Analyze_WithOutputFile_DatabaseCorrect (
197+ public async Task Analyze_WithOutputFile_DatabaseCorrect (
184198 [ Values ( "-o my_database" , "--output-file my_database" ) ] string options )
185199 {
186200 var databasePath = Path . Combine ( m_TestOutputFolder , "my_database" ) ;
187201 var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
188202
189- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
203+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath } . Concat ( options . Split ( " " ) ) . ToArray ( ) ) ) ;
190204
191205 ValidateDatabase ( databasePath , false ) ;
192206 }
@@ -263,12 +277,12 @@ public void Teardown()
263277 }
264278
265279 [ Test ]
266- public void Analyze_PlayerData_DatabaseCorrect ( )
280+ public async Task Analyze_PlayerData_DatabaseCorrect ( )
267281 {
268282 var databasePath = Path . Combine ( m_TestOutputFolder , "database.db" ) ;
269283 var analyzePath = Path . Combine ( Context . UnityDataFolder ) ;
270284
271- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "analyze" , analyzePath , "-r" } ) ) ;
285+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "analyze" , analyzePath , "-r" } ) ) ;
272286
273287 using var db = new SQLiteConnection ( $ "Data Source={ databasePath } ;Version=3;New=True;Foreign Keys=False;") ;
274288 db . Open ( ) ;
@@ -294,12 +308,12 @@ public void Analyze_PlayerData_DatabaseCorrect()
294308 }
295309
296310 [ Test ]
297- public void DumpText_PlayerData_TextFileCreatedCorrectly ( )
311+ public async Task DumpText_PlayerData_TextFileCreatedCorrectly ( )
298312 {
299313 var path = Path . Combine ( Context . UnityDataFolder , "level0" ) ;
300314 var outputFile = Path . Combine ( m_TestOutputFolder , "level0.txt" ) ;
301315
302- Assert . AreEqual ( 0 , Program . Main ( new string [ ] { "dump" , path } ) ) ;
316+ Assert . AreEqual ( 0 , await Program . Main ( new string [ ] { "dump" , path } ) ) ;
303317 Assert . IsTrue ( File . Exists ( outputFile ) ) ;
304318
305319 var content = File . ReadAllText ( outputFile ) ;
0 commit comments