コード例 #1
0
 public static void ClassInitialize(TestContext context)
 {
     try
     {
         client = ClientTests.CreateClient();
     }
     catch (Exception e)
     {
         Assert.Inconclusive("prerequisite: unable to create client.  Error: {0}", e.Message);
     }
 }
コード例 #2
0
        public void TestNamespaceInHeader()
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            var ns = appConfig["AWSNamespace"];

            Assert.IsNotNull(ns);

            var config = new AmazonS3Config()
                         .WithNamespace(ns);

            using (var client = ClientTests.CreateClient(config: config))
            {
                var buckets = client.ListBuckets();
                foreach (var bucket in buckets.Buckets)
                {
                    Debug.WriteLine(string.Format("Bucket: {0}", bucket.BucketName));
                }
            }
        }
コード例 #3
0
        public void TestInvalidNamespace()
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            string ns = Guid.NewGuid().ToString("N");

            var config = new AmazonS3Config()
                         .WithNamespace(ns);

            using (var client = ClientTests.CreateClient(config: config))
            {
                try
                {
                    using (var response = client.ListBuckets())
                    {
                        Assert.Fail("expected failure");
                    }
                }
                catch (AmazonS3Exception ex)
                {
                    Assert.AreEqual("InvalidNamespace", ex.ErrorCode);
                }
            }
        }