public void Delete_existing_container() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; string containerName = Guid.NewGuid().ToString(); // // Create container Assert.DoesNotThrow(() => { var tsk = swiftclient.CreateContainer(containerName, tokenSource.Token); containerCollection = tsk.Result; }); Assert.NotNull(containerCollection); Assert.True(containerCollection.Any(c => c.Name.Equals(containerName))); ContainerCollection containerCollection2 = null; Container container = containerCollection.First(c => c.Name.Equals(containerName)); // // Delete this container Assert.DoesNotThrow(() => { var tsk1 = swiftclient.DeleteContainer(container, tokenSource.Token); containerCollection2 = tsk1.Result; }); // // Is not exist in new list Assert.False(containerCollection2.Any(c => c.Name.Equals(containerName))); }
public void Delete_unknown_container_should_fail() { swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containersCollection = null; Assert.DoesNotThrow(() => { var tsk = swiftclient.GetContainers(tokenSource.Token); containersCollection = tsk.Result; }); Assert.NotNull(containersCollection); string validUri = containersCollection.First().Endpoint.ToString(); validUri = validUri.Substring(0, validUri.LastIndexOf("/")); Container badContainer = new Container() { Endpoint = new Uri(validUri + "/" + "##I_am_super_bad##") }; Assert.Throws(typeof(AggregateException), () => { var tsk = swiftclient.DeleteContainer(badContainer, tokenSource.Token); var coll = tsk.Result; Assert.Null(coll); }); }
public void Should_throw_on_container_that_does_not_exist() { byte[] bRndName = new byte[10]; new Random().NextBytes(bRndName); string containerName = System.Text.Encoding.Default.GetString(bRndName); swiftConnectionData = KeystoneData.GetKeystoneToken(); tokenSource = new CancellationTokenSource(); swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant); ContainerCollection containerCollection = null; Assert.DoesNotThrow(() => { var tsk = swiftclient.GetContainers(tokenSource.Token); containerCollection = tsk.Result; }); // // Check that it does not exist Assert.False(containerCollection.Any(c => c.Name.Equals(containerName))); // // Should throw Assert.Throws(typeof(ArgumentNullException), () => { var tsk2 = swiftclient.DeleteContainer(containerName, tokenSource.Token); }); }