19
19
using Xunit ;
20
20
using System . Text ;
21
21
using System . IO ;
22
+ using System . Linq ;
23
+ using System . Threading . Tasks ;
22
24
23
25
24
26
namespace StorageTransfer . Samples . Tests ;
@@ -38,12 +40,18 @@ public DownloadToPosixTest(StorageFixture fixture, ITestOutputHelper outputHelpe
38
40
public void DownloadToPosix ( )
39
41
{
40
42
DownloadToPosixSample downloadToPosixSample = new DownloadToPosixSample ( _outputHelper ) ;
43
+ Directory . CreateDirectory ( _fixture . TempDirectory ) ;
41
44
var storage = StorageClient . Create ( ) ;
42
45
byte [ ] byteArray = Encoding . UTF8 . GetBytes ( "flower.jpeg" ) ;
43
46
MemoryStream stream = new MemoryStream ( byteArray ) ;
44
- storage . UploadObject ( _fixture . BucketNameSource , "DownloadToPosixTestFile" , "application/octet-stream" , stream ) ;
45
- var transferJob = downloadToPosixSample . DownloadToPosix ( _fixture . ProjectId , _fixture . SinkAgentPoolName , _fixture . BucketNameSource , _fixture . GcsSourcePath , _fixture . RootDirectory ) ;
47
+ string fileName = $ "{ _fixture . GcsSourcePath } { DateTime . Now . ToString ( "yyyyMMddHHmmss" ) } .txt";
48
+ string filePath = $ "{ _fixture . TempDirectory } /{ fileName . Split ( '/' ) . Last ( ) } ";
49
+ storage . UploadObject ( _fixture . BucketNameSource , fileName , "application/octet-stream" , stream ) ;
50
+ var transferJob = downloadToPosixSample . DownloadToPosix ( _fixture . ProjectId , _fixture . SinkAgentPoolName , _fixture . BucketNameSource , _fixture . GcsSourcePath , _fixture . TempDirectory ) ;
46
51
Assert . Contains ( "transferJobs/" , transferJob . Name ) ;
52
+ Assert . True ( Directory . Exists ( _fixture . TempDirectory ) ) ;
53
+ System . Threading . Thread . Sleep ( TimeSpan . FromSeconds ( 45 ) ) ;
54
+ Assert . True ( File . Exists ( filePath ) ) ;
47
55
_transferJobName = transferJob . Name ;
48
56
}
49
57
@@ -61,6 +69,7 @@ public void Dispose()
61
69
Status = TransferJob . Types . Status . Deleted
62
70
}
63
71
} ) ;
72
+ Directory . Delete ( _fixture . TempDirectory , true ) ;
64
73
}
65
74
catch ( Exception )
66
75
{
0 commit comments