private static void CreateTrash(string parentPath, string name, int minRetentionTime, int sizeQuota, int bagCapacity, bool isAct) { var parent = Node.LoadNode(parentPath); var tb = new TrashBin(parent) { Name = name, IsActive = isAct, BagCapacity = bagCapacity, MinRetentionTime = minRetentionTime, SizeQuota = sizeQuota }; tb.Save(); }
public void Notification_Event_DeleteRestore() { var trash = Node.Load<TrashBin>("/Root/Trash"); if (trash == null) { trash = new TrashBin(Repository.Root); trash.Name = "Trash"; trash.IsActive = true; trash.Save(); } else { if (!trash.IsActive) { trash.IsActive = true; trash.Save(); } } TrashBin.Purge(); var source = Content.CreateNew("Folder", TestRoot, "DeleteRestore"); source.Save(); var doc = Content.CreateNew("Car", source.ContentHandler, "car_DeleteRestore"); doc.Save(); Subscription.Subscribe(Subscriber1, TestRoot, NotificationFrequency.Daily, "en", TESTSITEPATH, TESTSITEURL); Configuration.Enabled = true; source.Delete(); var bags = TrashBin.Instance.Children.OfType<TrashBag>().ToArray(); var bag = bags.FirstOrDefault(x => ((TrashBag)x).DeletedContent.Path.EndsWith("/DeleteRestore")); if (bag == null) Assert.Inconclusive(); TrashBin.Restore(bag); Configuration.Enabled = false; var events = (Event[])Event.GetAllEvents(); Assert.IsTrue(events.Length == 2, "#1"); Assert.IsTrue(events[0].NotificationType == NotificationType.Deleted, "#2"); Assert.IsTrue(events[0].ContentPath == source.Path, String.Concat("#3: Path is: ", events[0].ContentPath, ", expected: ", source.Path)); Assert.IsTrue(events[1].NotificationType == NotificationType.Restored, "#4"); Assert.IsTrue(events[1].ContentPath == source.Path, String.Concat("#5: Path is: ", events[1].ContentPath, ", expected: ", source.Path)); }