public void GetParentIdNullTest() { Id baseId = new Id("aOwner", "aDate", "aCollection", "aPath"); Id parent = baseId.GetParentId(); Assert.IsNull(parent); }
public void DeleteEntry(Id entryId) { string path = pathResolver.GetEntryPath(entryId); if (!System.IO.File.Exists(path)) throw new ResourceNotFoundException("entry", entryId.ToString()); System.IO.File.Delete(path); //delete annotations string dir = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), System.IO.Path.GetFileNameWithoutExtension(path)); if (System.IO.Directory.Exists(dir)) { try { foreach (string file in Directory.GetFiles(dir, "*" + PathResolver.DefaultEntryExt, SearchOption.AllDirectories)) System.IO.File.Delete(file); foreach (string file in Directory.GetFiles(dir, "*" + PathResolver.DefaultMediaLinkEntryExt, SearchOption.AllDirectories)) System.IO.File.Delete(file); //try and clean up old directories //don't delete directory because it causes application restart //System.IO.Directory.Delete(dir, true); //AtomSite.Utils.FileHelper.RemoveEmptyPaths(pathResolver.GetCollectionPath(entryId), true); } catch (Exception ex) { System.Diagnostics.Trace.TraceError(ex.Message); } } //clear parent from cache if (entryId.IsAnnotation) { string parent = pathResolver.GetEntryPath(entryId.GetParentId()); entries.Clear(parent); } }
[TestMethod] public void GetParentIdValidTest() { Id baseId = new Id("aOwner", "aDate", "aCollection", "aPath"); Id ChildId = new Id(baseId.Owner, baseId.Date, baseId.Collection, baseId.EntryPath + ", bPath"); Id parent = ChildId.GetParentId(); Assert.IsNotNull(parent); Assert.AreEqual(baseId.Owner, parent.Owner); Assert.AreEqual(baseId.Date, parent.Date); Assert.AreEqual(baseId.Collection, parent.Collection); Assert.AreEqual(baseId.EntryPath, parent.EntryPath); }