private void emptyTrashCanDo(RecycleBin.RecycleBinType type) { var trashCan = new RecycleBin(type); var callback = new Action <int>(x => { Application.Lock(); Application["trashcanEmptyLeft"] = x.ToString(); Application.UnLock(); }); trashCan.CallTheGarbageMan(callback); }
public void Media_Empty_Recycle_Bin() { //System.Diagnostics.Debugger.Break(); var mediaList = new List <Media>(); var total = 20; var mt = m_ExistingMediaType; //allow the doc type to be created underneath itself mt.AllowedChildContentTypeIDs = new int[] { mt.Id }; mt.Save(); //create 20 media nodes underneath each other, this will test deleting with heirarchy as well var lastParentId = -1; for (var i = 0; i < total; i++) { var newMedia = Media.MakeNew("R-" + i.ToString() + Guid.NewGuid().ToString("N"), mt, m_User, lastParentId); mediaList.Add(newMedia); Assert.IsTrue(mediaList[mediaList.Count - 1].Id > 0); Assert.AreEqual(lastParentId, newMedia.ParentId); lastParentId = newMedia.Id; } //now delete all of them, since they are nested, we only need to delete one mediaList.First().delete(); //a callback action for each item removed from the recycle bin var totalDeleted = 0; var bin = new RecycleBin(RecycleBin.RecycleBinType.Media); var totalTrashedItems = bin.GetDescendants().Cast <object>().Count(); bin.CallTheGarbageMan(x => { Assert.AreEqual(totalTrashedItems - (++totalDeleted), x); }); Assert.AreEqual(0, RecycleBin.Count(RecycleBin.RecycleBinType.Media)); }
public void Document_Empty_Recycle_Bin() { var docList = new List <Document>(); var total = 20; var dt = m_ExistingDocType; //allow the doc type to be created underneath itself dt.AllowedChildContentTypeIDs = new int[] { dt.Id }; dt.Save(); //create 20 content nodes underneath each other, this will test deleting with heirarchy as well var lastParentId = -1; for (var i = 0; i < total; i++) { var newDoc = Document.MakeNew("R-" + i.ToString() + Guid.NewGuid().ToString("N"), dt, m_User, lastParentId); docList.Add(newDoc); Assert.IsTrue(docList[docList.Count - 1].Id > 0); Assert.AreEqual(lastParentId, newDoc.ParentId); lastParentId = newDoc.Id; } //now delete all of them, since they are nested, we only need to delete one docList.First().delete(); //a callback action for each item removed from the recycle bin var totalDeleted = 0; var bin = new RecycleBin(RecycleBin.RecycleBinType.Content); var totalTrashedItems = bin.GetDescendants().Cast <object>().Count(); bin.CallTheGarbageMan(x => { Assert.AreEqual(totalTrashedItems - (++totalDeleted), x); }); Assert.AreEqual(0, RecycleBin.Count(RecycleBin.RecycleBinType.Content)); }