public async Task Error_IfCredentialsAreInvalidAndThrowExceptionOnErrorResponseIsFalse() { var input = new UploadInput { FileMask = "TestFile1.csv", FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../../TestData/"), S3Directory = @"\" }; var options = new UploadOptions { ReturnListOfObjectKeys = true, ThrowErrorIfNoMatch = true }; var param = new Parameters { // Invalid AwsAccesKeyId. AwsAccessKeyId = "fnvfdvfkdjvn", // Invalid AwsSecretAccessKey. AwsSecretAccessKey = "bvfjhbvdjhvbjdhf", BucketName = Environment.GetEnvironmentVariable("HiQ_AWSS3Test_BucketName"), Region = (Regions)int.Parse(Environment.GetEnvironmentVariable("HiQ_AWSS3Test_Region")), ThrowExceptionOnErrorResponse = false }; async Task <List <string> > UploadThatThrows() { var response = await UploadTask.UploadFiles(input, param, options, new CancellationToken()); return(response); } try { await UploadThatThrows(); } catch (Exception ex) { Assert.Fail("Expected no exception, but got: " + ex.Message); } }
public void Error_IfSourcePathIsInvalid() { var input = new UploadInput { FileMask = @"*.test", FilePath = @"c:\there_is_no_folder_like_this\" }; var options = new UploadOptions { ReturnListOfObjectKeys = true, ThrowErrorIfNoMatch = true }; void UploadThatThrows() { UploadTask.UploadFiles(input, _param, options, new CancellationToken()); } Assert.That(UploadThatThrows, Throws.TypeOf <ArgumentException>() .With.Message.StartsWith("Source path not found.")); }
public void Error_IfCredentialsAreInvalidAndThrowExceptionOnErrorResponseIsTrue() { var input = new UploadInput { FileMask = "TestFile1.csv", FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../../TestData/"), S3Directory = @"\", CannedACL = S3CannedACLs.Private }; var options = new UploadOptions { ReturnListOfObjectKeys = true, ThrowErrorIfNoMatch = true }; var param = new Parameters { // Invalid AwsAccesKeyId. AwsAccessKeyId = "fnvfdvfkdjvn", // Invalid AwsSecretAccessKey. AwsSecretAccessKey = "bvfjhbvdjhvbjdhf", BucketName = Environment.GetEnvironmentVariable("HiQ_AWSS3Test_BucketName"), Region = (Regions)int.Parse(Environment.GetEnvironmentVariable("HiQ_AWSS3Test_Region")), ThrowExceptionOnErrorResponse = true }; async Task <List <string> > UploadThatThrows() { var response = await UploadTask.UploadFiles(input, param, options, new CancellationToken()); return(response); } Assert.That(UploadThatThrows, Throws.TypeOf <SecurityException>().With.Message.StartsWith("Invalid Amazon S3 Credentials - data was not uploaded.")); }
public void Error_IfSwitchIsOnAndNothingMatches() { var input = new UploadInput { FileMask = "there_is_no_spoon.text", FilePath = Path.GetTempPath(), S3Directory = @"\" }; var options = new UploadOptions { ReturnListOfObjectKeys = true, ThrowErrorIfNoMatch = true }; void UploadThatThrows() { UploadTask.UploadFiles(input, _param, options, new CancellationToken()); } Assert.That(UploadThatThrows, Throws.TypeOf <ArgumentException>() .With.Message.StartsWith("No files match the filemask within supplied path.")); }