public void CreateBucket()
        {
            string testBucketName = "UnitTestBucket";
            var api = new ServiceStackB2Api();

            var returnBucket = api.CreateBucket(testBucketName, true);
            Assert.AreEqual(returnBucket.BucketName, testBucketName);
            Assert.AreEqual(returnBucket.AccountId, api.GetApplicationCredentials().AccountId);
            Assert.AreEqual(returnBucket.BucketType, "allPrivate");
        }
Beispiel #2
0
        public void ListBuckets()
        {
            string testBucketName = "ListBucketsTestBucket";
            var api = new ServiceStackB2Api();

            var createdBucket = api.CreateBucket(testBucketName, true);

            Assert.AreEqual(createdBucket.BucketName, testBucketName);
            Assert.AreEqual(createdBucket.AccountId, api.GetApplicationCredentials().AccountId);
            Assert.AreEqual(createdBucket.BucketType, "allPrivate");

            var listBuckets = api.ListBuckets();
            var testBucket = listBuckets.Buckets.FirstOrDefault(b => b.BucketName == createdBucket.BucketName);

            Assert.AreEqual(testBucket.BucketName, createdBucket.BucketName);
            Assert.AreEqual(testBucket.BucketType, createdBucket.BucketType);
            Assert.AreEqual(testBucket.AccountId, createdBucket.AccountId);
            Assert.AreEqual(testBucket.BucketId, createdBucket.BucketId);
        }
        public void CreateEmptyTestBuckets()
        {
            var client = new ServiceStackB2Api();

            var bucketNames = new List<String>()
            {
                "ListFileNamesTestBucket",
                "FileUploadTestBucket",
                "FileDownloadTestBucket",
            };

            try
            {
                bucketNames.ForEach(b => client.CreateBucket(b));
            }

            catch (DuplicateBucketException)
            {
                Assert.Fail("Test buckets were already created - please clean them up and try again");
            }
        }
Beispiel #4
0
        public void TestListFileNames()
        {
            var client = new ServiceStackB2Api();
            List<UploadFileResponse> uploadedList = new List<UploadFileResponse>();

            var bucket = client.CreateBucket("ListFileNamesTestBucket");

            MemoryStream fileContents = new MemoryStream(Encoding.UTF8.GetBytes("Hello World"));

            var request = new FileUploadRequest
            {
                FileContents = fileContents,
                ContentSHA1 = null,
                FileName = "one.txt",
                ContentType = "text/plain"
            };

            uploadedList.Add(client.UploadFile(request));
            request.FileContents.Seek(0, SeekOrigin.Begin);

            request.FileName = "two.txt";
            uploadedList.Add(client.UploadFile(request));
            request.FileContents.Seek(0, SeekOrigin.Begin);

            request.FileName = "three.txt";
            uploadedList.Add(client.UploadFile(request));
            request.FileContents.Seek(0, SeekOrigin.Begin);

            request.FileName = "four.txt";
            uploadedList.Add(client.UploadFile(request));
            request.FileContents.Seek(0, SeekOrigin.Begin);

            var response = client.ListFileNames(new ListFileNamesRequest() {BucketId = bucket.BucketId});
            foreach (var responseFile in response.Files)
            {
                Assert.IsTrue(uploadedList.Contains(responseFile));
            }
        }
 private void CreateDuplicateBucket()
 {
     var client = new ServiceStackB2Api();
     client.CreateBucket("DuplicateTestBucket");
     client.CreateBucket("DuplicateTestBucket");
 }