public void Delete_all_objects_for_all_containers() { 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; }); Assert.NotNull(containerCollection); List<Tuple<Container, SwiftObjectsCollection>> listOfEverything = new List<Tuple<Container,SwiftObjectsCollection>>(); containerCollection.ForEach(container => { Assert.DoesNotThrow(() => { var tsk2 = swiftclient.GetObjects(container, tokenSource.Token); listOfEverything.Add(new Tuple<Container, SwiftObjectsCollection>(container, tsk2.Result)); }); }); Assert.True(listOfEverything.Count > 0); foreach (Tuple<Container, SwiftObjectsCollection> record in listOfEverything) { SwiftObjectsCollection originalCollection = record.Item2; SwiftObjectsCollection generatedCollection = null; originalCollection.ForEach(obj => { Assert.DoesNotThrow(()=>{ System.Diagnostics.Trace.WriteLine("[Objects] Going to delete object: " + obj.Name + " from container: " + record.Item1.Name); var tsk3 = swiftclient.DeleteObject(record.Item1, obj, tokenSource.Token); generatedCollection = tsk3.Result; }); Assert.NotNull(generatedCollection); Assert.False(originalCollection.Intersect(generatedCollection).Count() == originalCollection.Count); }); } }
public void Delete_unknown_object_from_container_should_throw() { 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; }); Assert.NotNull(containerCollection); Container container = containerCollection.First(); SwiftObject badObject = new SwiftObject() { Name = "##I_am_super_bad##"}; Assert.Throws(typeof(AggregateException), () => { var tsk = swiftclient.DeleteObject(container, badObject, tokenSource.Token); var coll = tsk.Result; Assert.NotNull(coll); }); }