@@ -244,5 +244,39 @@ public void CS_Ptr_Defaults_Off()
244244 // Assert
245245 Assert . That ( url , Is . EqualTo ( "https://raw.githubusercontent.com/simulationcraft/simc/test_branch/engine/dbc/generated/test.inc" ) ) ;
246246 }
247+
248+ [ Test ]
249+ public async Task CS_ClearCache_Deletes_Files_And_Recovers ( )
250+ {
251+ // Arrange
252+ CacheService cache = new CacheService ( null , _loggerFactory . CreateLogger < CacheService > ( ) ) ;
253+
254+ var configuration = new CacheFileConfiguration ( )
255+ {
256+ LocalParsedFile = "CombatRatingMultipliers.json" ,
257+ ParsedFileType = SimcParsedFileType . CombatRatingMultipliers ,
258+ RawFiles = new Dictionary < string , string > ( )
259+ {
260+ { "ScaleData.raw" , "sc_scale_data" }
261+ }
262+ } ;
263+ var filePath = Path . Combine ( cache . BaseFileDirectory , "ScaleData.raw" ) ;
264+
265+ // Ensure a file exists by downloading it
266+ _ = await cache . GetRawFileContentsAsync ( configuration , "ScaleData.raw" ) ;
267+ FileAssert . Exists ( filePath ) ;
268+
269+ // Act: clear the cache
270+ await cache . ClearCacheAsync ( ) ;
271+
272+ // Assert: file was deleted
273+ Assert . That ( File . Exists ( filePath ) , Is . False , "Cache file should be removed after clear." ) ;
274+
275+ // Act again: accessing should re-download
276+ _ = await cache . GetRawFileContentsAsync ( configuration , "ScaleData.raw" ) ;
277+
278+ // Assert: file is back
279+ FileAssert . Exists ( filePath ) ;
280+ }
247281 }
248282}
0 commit comments