88using SharpGrip . FileSystem . Models ;
99using Xunit ;
1010
11- namespace Tests . FileSystem . Adapters . AmazonS3 ;
12-
13- public class AmazonS3AdapterTest
11+ namespace Tests . FileSystem . Adapters . AmazonS3
1412{
15- [ Fact ]
16- public void Test_Instantiation ( )
13+ public class AmazonS3AdapterTest
1714 {
18- var amazonS3Client = new Mock < AmazonS3Client > ( "awsAccessKeyId" , "awsSecretAccessKey" , RegionEndpoint . USEast2 ) ;
19- var amazonS3Adapter = new AmazonS3Adapter ( "prefix" , "/root-path" , amazonS3Client . Object , "bucket" ) ;
15+ [ Fact ]
16+ public void Test_Instantiation ( )
17+ {
18+ var amazonS3Client = new Mock < AmazonS3Client > ( "awsAccessKeyId" , "awsSecretAccessKey" , RegionEndpoint . USEast2 ) ;
19+ var amazonS3Adapter = new AmazonS3Adapter ( "prefix" , "/root-path" , amazonS3Client . Object , "bucket" ) ;
2020
21- Assert . Equal ( "prefix" , amazonS3Adapter . Prefix ) ;
22- Assert . Equal ( "/root-path" , amazonS3Adapter . RootPath ) ;
23- }
21+ Assert . Equal ( "prefix" , amazonS3Adapter . Prefix ) ;
22+ Assert . Equal ( "/root-path" , amazonS3Adapter . RootPath ) ;
23+ }
2424
25- [ Fact ]
26- public async Task Test_Get_File_Async ( )
27- {
28- var amazonS3Client = new Mock < AmazonS3Client > ( "awsAccessKeyId" , "awsSecretAccessKey" , RegionEndpoint . USEast2 ) ;
29- var amazonS3Adapter = new AmazonS3Adapter ( "prefix-1" , "/root-path-1" , amazonS3Client . Object , "bucket-1" ) ;
25+ [ Fact ]
26+ public async Task Test_Get_File_Async ( )
27+ {
28+ var amazonS3Client = new Mock < AmazonS3Client > ( "awsAccessKeyId" , "awsSecretAccessKey" , RegionEndpoint . USEast2 ) ;
29+ var amazonS3Adapter = new AmazonS3Adapter ( "prefix-1" , "/root-path-1" , amazonS3Client . Object , "bucket-1" ) ;
3030
31- var getObjectResponse = new Mock < GetObjectResponse > ( ) ;
31+ var getObjectResponse = new Mock < GetObjectResponse > ( ) ;
3232
33- getObjectResponse . SetupAllProperties ( ) ;
34- getObjectResponse . Object . Key = "test.txt" ;
35- getObjectResponse . Object . ContentLength = 1 ;
36- getObjectResponse . Object . LastModified = new DateTime ( 1970 , 1 , 1 ) ;
33+ getObjectResponse . SetupAllProperties ( ) ;
34+ getObjectResponse . Object . Key = "test.txt" ;
35+ getObjectResponse . Object . ContentLength = 1 ;
36+ getObjectResponse . Object . LastModified = new DateTime ( 1970 , 1 , 1 ) ;
3737
38- amazonS3Client . Setup ( o => o . GetObjectAsync ( "bucket-1" , "/root-path-1\\ test.txt" , default ) ) . ReturnsAsync ( getObjectResponse . Object ) ;
38+ amazonS3Client . Setup ( o => o . GetObjectAsync ( "bucket-1" , "/root-path-1\\ test.txt" , default ) ) . ReturnsAsync ( getObjectResponse . Object ) ;
3939
40- var fileModel = new FileModel
41- {
42- Name = "test.txt" ,
43- Path = "test.txt" ,
44- Length = 1 ,
45- LastModifiedDateTime = new DateTime ( 1970 , 1 , 1 )
46- } ;
47-
48- var result = await amazonS3Adapter . GetFileAsync ( "test.txt" ) ;
49-
50- Assert . Equal ( fileModel . Name , result . Name ) ;
51- Assert . Equal ( fileModel . Path , result . Path ) ;
52- Assert . Equal ( fileModel . Length , result . Length ) ;
53- Assert . Equal ( fileModel . LastModifiedDateTime , result . LastModifiedDateTime ) ;
40+ var fileModel = new FileModel
41+ {
42+ Name = "test.txt" ,
43+ Path = "test.txt" ,
44+ Length = 1 ,
45+ LastModifiedDateTime = new DateTime ( 1970 , 1 , 1 )
46+ } ;
47+
48+ var result = await amazonS3Adapter . GetFileAsync ( "test.txt" ) ;
49+
50+ Assert . Equal ( fileModel . Name , result . Name ) ;
51+ Assert . Equal ( fileModel . Path , result . Path ) ;
52+ Assert . Equal ( fileModel . Length , result . Length ) ;
53+ Assert . Equal ( fileModel . LastModifiedDateTime , result . LastModifiedDateTime ) ;
54+ }
5455 }
5556}
0 commit comments