示例#1
0
        private AmazonS3CabinetConfig GetConfig(string bucketName, string keyPrefix = null)
        {
            var config = new AmazonS3CabinetConfig(bucketName, RegionEndpoint.APSoutheast2, null)
            {
                KeyPrefix = keyPrefix
            };

            return(config);
        }
示例#2
0
        public async Task Save_File_Stream_Null_Config_Throws()
        {
            var provider = GetProvider();
            AmazonS3CabinetConfig config = null;
            var mockStream   = new Mock <Stream>();
            var mockProgress = new Mock <IProgress <IWriteProgress> >();

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
                                                             await provider.SaveFileAsync(ValidFileKey, mockStream.Object, HandleExistingMethod.Overwrite, mockProgress.Object, config)
                                                             );
        }
示例#3
0
        public async Task Save_File_Path_Config_Throws()
        {
            var provider = GetProvider();
            AmazonS3CabinetConfig config = null;
            string filePath     = @"C:\test\test.txt";
            var    mockProgress = new Mock <IProgress <IWriteProgress> >();

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
                                                             await provider.SaveFileAsync(ValidFileKey, filePath, HandleExistingMethod.Overwrite, mockProgress.Object, config)
                                                             );
        }
示例#4
0
        public async Task Move_File_Path_Null_Config_Throws()
        {
            var provider = GetProvider();
            AmazonS3CabinetConfig config = null;
            string sourceKey             = @"source.txt";
            string destKey      = @"dest.txt";
            var    mockProgress = new Mock <IProgress <IWriteProgress> >();

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
                                                             await provider.MoveFileAsync(sourceKey, destKey, HandleExistingMethod.Overwrite, config)
                                                             );
        }
示例#5
0
        public void Get_S3_Client_Sets_Credentails_And_Config()
        {
            var s3Config = new AmazonS3Config()
            {
                RegionEndpoint = Amazon.RegionEndpoint.USEast1,
            };

            var mockCredentials = new Mock <AWSCredentials>();

            var config = new AmazonS3CabinetConfig(ValidBucketName, s3Config, mockCredentials.Object);

            var client = factory.GetS3Client(config) as AmazonS3Client;

            Assert.NotNull(client);
            Assert.Equal(s3Config, client.Config);
        }
        public void Get_Set_Bucket_Name()
        {
            var config = new AmazonS3CabinetConfig(ValidBucketName, mockS3Config.Object, mockS3Credentials.Object);

            Assert.Equal(ValidBucketName, config.BucketName);
        }
示例#7
0
 public async Task List_Keys_Null_Config_Throws()
 {
     var provider = GetProvider();
     AmazonS3CabinetConfig config = null;
     await Assert.ThrowsAsync <ArgumentNullException>(async() => await provider.ListKeysAsync(config));
 }
示例#8
0
 public async Task Delete_File_Null_Config_Throws()
 {
     var provider = GetProvider();
     AmazonS3CabinetConfig config = null;
     await Assert.ThrowsAsync <ArgumentNullException>(async() => await provider.DeleteFileAsync(ValidFileKey, config));
 }
示例#9
0
 public async Task Open_Read_Stream_Null_Config_Throws()
 {
     var provider = GetProvider();
     AmazonS3CabinetConfig config = null;
     await Assert.ThrowsAsync <ArgumentNullException>(async() => await provider.OpenReadStreamAsync(ValidFileKey, config));
 }