1515
1616namespace Tests . FileSystem . Adapters . AmazonS3
1717{
18- public class AmazonS3AdapterTest
18+ public class AmazonS3AdapterTest : IAdapterTests
1919 {
2020 private readonly AmazonS3Exception amazonS3NoSuchKeyException = new ( "NoSuchKey" , ErrorType . Receiver , "NoSuchKey" , "12345" , HttpStatusCode . NotFound ) ;
2121 private readonly AmazonS3Exception amazonS3InvalidAccessKeyIdException = new ( "InvalidAccessKeyId" , ErrorType . Receiver , "InvalidAccessKeyId" , "12345" , HttpStatusCode . Unauthorized ) ;
@@ -31,6 +31,12 @@ public void Test_Instantiation()
3131 Assert . Equal ( "/root-path" , amazonS3Adapter . RootPath ) ;
3232 }
3333
34+ [ Fact ]
35+ public async Task Test_Connect ( )
36+ {
37+ await Task . CompletedTask ;
38+ }
39+
3440 [ Fact ]
3541 public async Task Test_Get_File_Async ( )
3642 {
@@ -294,6 +300,30 @@ public async Task Test_Create_Directory_Async()
294300 await fileSystem . CreateDirectoryAsync ( "prefix-1://test5" ) ;
295301 }
296302
303+ [ Fact ]
304+ public async Task Test_Delete_File_Async ( )
305+ {
306+ var amazonS3Client = Substitute . For < IAmazonS3 > ( ) ;
307+ var amazonS3Adapter = new AmazonS3Adapter ( "prefix-1" , "root-path-1" , amazonS3Client , "bucket-1" ) ;
308+ var fileSystem = new SharpGrip . FileSystem . FileSystem ( new List < IAdapter > { amazonS3Adapter } ) ;
309+
310+ var getObjectResponse = Substitute . For < GetObjectResponse > ( ) ;
311+
312+ getObjectResponse . Key = "test4.txt" ;
313+ getObjectResponse . ContentLength = 1 ;
314+ getObjectResponse . LastModified = new DateTime ( 1970 , 1 , 1 ) ;
315+
316+ amazonS3Client . GetObjectAsync ( "bucket-1" , "root-path-1/test1.txt" ) . ThrowsAsync ( amazonS3NoSuchKeyException ) ;
317+ amazonS3Client . GetObjectAsync ( "bucket-1" , "root-path-1/test2.txt" ) . ThrowsAsync ( amazonS3InvalidAccessKeyIdException ) ;
318+ amazonS3Client . GetObjectAsync ( "bucket-1" , "root-path-1/test3.txt" ) . ThrowsAsync ( amazonS3InvalidSecurityException ) ;
319+ amazonS3Client . GetObjectAsync ( "bucket-1" , "root-path-1/test4.txt" ) . Returns ( getObjectResponse ) ;
320+
321+ await Assert . ThrowsAsync < FileNotFoundException > ( ( ) => fileSystem . DeleteFileAsync ( "prefix-1://test1.txt" ) ) ;
322+ await Assert . ThrowsAsync < ConnectionException > ( ( ) => fileSystem . DeleteFileAsync ( "prefix-1://test2.txt" ) ) ;
323+ await Assert . ThrowsAsync < ConnectionException > ( ( ) => fileSystem . DeleteFileAsync ( "prefix-1://test3.txt" ) ) ;
324+ await fileSystem . DeleteFileAsync ( "prefix-1://test4.txt" ) ;
325+ }
326+
297327 [ Fact ]
298328 public async Task Test_Delete_Directory_Async ( )
299329 {
@@ -325,5 +355,29 @@ public async Task Test_Delete_Directory_Async()
325355 await Assert . ThrowsAsync < ConnectionException > ( ( ) => fileSystem . DeleteDirectoryAsync ( "prefix-1://test4" ) ) ;
326356 await fileSystem . DeleteDirectoryAsync ( "prefix-1://test5" ) ;
327357 }
358+
359+ [ Fact ]
360+ public async Task Test_Read_File_Async ( )
361+ {
362+ await Task . CompletedTask ;
363+ }
364+
365+ [ Fact ]
366+ public async Task Test_Read_Text_File_Async ( )
367+ {
368+ await Task . CompletedTask ;
369+ }
370+
371+ [ Fact ]
372+ public async Task Test_Write_File_Async ( )
373+ {
374+ await Task . CompletedTask ;
375+ }
376+
377+ [ Fact ]
378+ public async Task Test_Append_File_Async ( )
379+ {
380+ await Task . CompletedTask ;
381+ }
328382 }
329383}
0 commit comments