public static void ClassInitialize(TestContext context) { try { client = ClientTests.CreateClient(); } catch (Exception e) { Assert.Inconclusive("prerequisite: unable to create client. Error: {0}", e.Message); } }
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)); } } }
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); } } }