public IQueryable <Subscription> GetSubscriptionsRecursive(SubscriptionFolder root) { var folderIds = new HashSet <int>(); var queue = new Queue <SubscriptionFolder>(); queue.Enqueue(root); // Build set of subfolders while (queue.TryDequeue(out SubscriptionFolder current)) { if (folderIds.Contains(current.Id)) { Debug.Fail($"Folder cycle detected for id {current.Id}!!!"); continue; } folderIds.Add(current.Id); SubscriptionFolders.AsQueryable() .Where(f => f.ParentId == current.Id) .ForEach(queue.Enqueue); } // Get subscriptions return(Subscriptions.AsQueryable() .Where(x => x.ParentFolderId.HasValue && folderIds.Contains(x.ParentFolderId.Value))); }
public void All_subscription_entries_for_specfied_message_types_should_be_removed() { Storage.Subscribe(TestClients.ClientA, MessageTypes.All); Storage.Unsubscribe(TestClients.ClientA, MessageTypes.All); var count = Subscriptions.AsQueryable().Count(s => s.Subscribers != null && s.Subscribers.Any()); Assert.AreEqual(0, count); }