コード例 #1
0
        public async Task UploadTestsAsync()
        {
            IAmazonS3     S3Client    = TestingS3Client;
            ICloudStorage sut         = new S3CloudStorage(S3Client);
            var           uploadItems = PrepareUploadItems().ToList();

            UploadResponse uploadResponse = await sut.UploadAsync(BucketName, uploadItems);

            Assert.Equal(ServiceStatusCode.OK, uploadResponse.StatusCode);
            Assert.Equal(2, uploadResponse.UploadedItems.Count);
            Assert.Collection(uploadResponse.UploadedItems,
                              item => Assert.Contains("First/1.jpg", item.KeyName),
                              item => Assert.Contains("Second/2.jpg", item.KeyName));

            Assert.Equal(3, uploadResponse.FailedItems.Count);

            foreach (var fitem in uploadResponse.FailedItems)
            {
                switch (fitem.Source.KeyName)
                {
                case "":
                case null:
                    Assert.Equal(UploadItemStatsCode.InvalidKeyName, fitem.StatusCode);
                    break;

                case "Well/Good.key":
                    Assert.Equal(UploadItemStatsCode.IOException, fitem.StatusCode);
                    break;
                }
            }
        }
コード例 #2
0
        public async Task TestUploadToNotExistingBucketAsync()
        {
            IAmazonS3     S3Client    = TestingS3Client;
            ICloudStorage fileStorage = new S3CloudStorage(S3Client);
            var           fileList    = PrepareUploadItems().ToList();

            UploadResponse uploadResponse = await fileStorage.UploadAsync(NotExistingBucket, fileList);

            Assert.Equal(ServiceStatusCode.BucketDoesNotExist, uploadResponse.StatusCode);
        }
コード例 #3
0
        public async Task TestUploadInvalidSocketAsync(string invalidBucketName)
        {
            IAmazonS3     S3Client = TestingS3Client;
            ICloudStorage sut      = new S3CloudStorage(S3Client);
            var           fileList = PrepareUploadItems().ToList();

            UploadResponse uploadResponse = await sut.UploadAsync(invalidBucketName, fileList);

            Assert.Equal(ServiceStatusCode.InvalidBucketName, uploadResponse.StatusCode);
        }