1- using System . Net ;
1+ using System . Net ;
22using static Storage . Tests . StorageFixture ;
33
44namespace Storage . Tests ;
@@ -8,8 +8,8 @@ public sealed class ObjectShould : IClassFixture<StorageFixture>
88 private readonly S3Client _client ;
99 private readonly CancellationToken _ct ;
1010 private readonly StorageFixture _fixture ;
11- private readonly S3Client _notExistsBucketClient ; // don't dispose it
12-
11+ private readonly S3Client _notExistsBucketClient ; // don't dispose it
12+
1313 public ObjectShould ( StorageFixture fixture )
1414 {
1515 _ct = CancellationToken . None ;
@@ -136,9 +136,9 @@ public async Task DisposeFileStream()
136136 public async Task DisposeStorageFile ( )
137137 {
138138 var fileName = await CreateTestFile ( ) ;
139- using var fileGetResult = await _client . GetFile ( fileName , _ct ) ;
140-
141- // ReSharper disable once DisposeOnUsingVariable
139+ using var fileGetResult = await _client . GetFile ( fileName , _ct ) ;
140+
141+ // ReSharper disable once DisposeOnUsingVariable
142142 fileGetResult . Dispose ( ) ;
143143
144144 await DeleteTestFile ( fileName ) ;
@@ -370,28 +370,28 @@ public async Task ReadFileStream()
370370
371371 var buffer = new byte [ 1024 ] ;
372372 var file = await _client . GetFile ( fileName , _ct ) ;
373- var fileStream = await file . GetStream ( _ct ) ;
374-
373+ var fileStream = await file . GetStream ( _ct ) ;
374+
375375#pragma warning disable CA1835
376376 var read = await fileStream . ReadAsync ( buffer , _ct ) ;
377377 read . Should ( ) . BeGreaterThan ( 0 ) ;
378378
379379 read = await fileStream . ReadAsync ( buffer , 10 , 20 , _ct ) ;
380- read . Should ( ) . BeGreaterThan ( 0 ) ;
381-
382- // ReSharper disable once MethodHasAsyncOverloadWithCancellation
380+ read . Should ( ) . BeGreaterThan ( 0 ) ;
381+
382+ // ReSharper disable once MethodHasAsyncOverloadWithCancellation
383383 read = fileStream . Read ( buffer , 10 , 20 ) ;
384- read . Should ( ) . BeGreaterThan ( 0 ) ;
384+ read . Should ( ) . BeGreaterThan ( 0 ) ;
385385#pragma warning restore CA1835
386-
386+
387387 await DeleteTestFile ( fileName ) ;
388388 }
389389
390390 [ Fact ]
391391 public async Task Upload ( )
392392 {
393393 var fileName = _fixture . Create < string > ( ) ;
394- using var data = GetByteStream ( 12 * 1024 * 1024 ) ; // 12 Mb
394+ using var data = GetByteStream ( 12 * 1024 * 1024 ) ; // 12 Mb
395395 var filePutResult = await _client . UploadFile ( fileName , StreamContentType , data , _ct ) ;
396396
397397 filePutResult
@@ -505,8 +505,27 @@ await _notExistsBucketClient
505505 await _notExistsBucketClient
506506 . Invoking ( client => client . UploadFile ( fileName , StreamContentType , fileArray , _ct ) )
507507 . Should ( ) . ThrowAsync < HttpRequestException > ( ) ;
508+ }
509+
510+ [ Theory ]
511+ [ InlineData ( "some/foo/audio.wav" , 1024 ) ]
512+ [ InlineData ( "another/path/test.mp3" , 2048 ) ]
513+ public async Task UploadFileWithNestedPath ( string nestedFileName , int dataSize )
514+ {
515+ var data = GetByteArray ( dataSize ) ; // Пример данных, которые вы хотите загрузить
516+
517+ // Act
518+ var result = await _client . UploadFile ( nestedFileName , StreamContentType , data , _ct ) ;
519+ Assert . True ( result ) ;
520+
521+ // Assert
522+ var exists = await _client . IsFileExists ( nestedFileName , _ct ) ;
523+ Assert . True ( exists , "The object should exist in the S3 bucket" ) ;
524+
525+ await DeleteTestFile ( nestedFileName ) ;
508526 }
509527
528+
510529 [ Fact ]
511530 public async Task ThrowIfUploadDisposed ( )
512531 {
@@ -534,8 +553,8 @@ private async Task<string> CreateTestFile(
534553 int ? size = null )
535554 {
536555 fileName ??= _fixture . Create < string > ( ) ;
537- using var data = GetByteStream ( size ?? 1 * 1024 * 1024 ) ; // 1 Mb
538-
556+ using var data = GetByteStream ( size ?? 1 * 1024 * 1024 ) ; // 1 Mb
557+
539558 var uploadResult = await _client . UploadFile ( fileName , contentType , data , _ct ) ;
540559
541560 uploadResult
@@ -570,8 +589,8 @@ private async Task EnsureFileSame(string fileName, MemoryStream expectedBytes)
570589 memoryStream
571590 . ToArray ( ) . SequenceEqual ( expectedBytes . ToArray ( ) )
572591 . Should ( ) . BeTrue ( ) ;
573- }
574-
592+ }
593+
575594 private Task DeleteTestFile ( string fileName )
576595 {
577596 return _client . DeleteFile ( fileName , _ct ) ;
0 commit comments