public MainWindowViewModel(DataRepository repo)
        {
            this.repo = repo.ThrowIfNull();

            feeds = new ObservableCollection<FeedViewModel>(
                repo.AllFeeds().Select(feed => new FeedViewModel(repo, feed)));
            feedItems = new ObservableCollection<FeedItemViewModel>(
                repo.AllFeedItems().Select(feedItem => new FeedItemViewModel(feedItem)));

            FeedsView = CollectionViewSource.GetDefaultView(feeds);
            FeedsView.CurrentChanged += HandleFeedsViewCurrentChanged;

            FeedItemsView = CollectionViewSource.GetDefaultView(feedItems);
            FeedItemsView.Filter = FeedItemsViewFilter;
            FeedItemsView.SortDescriptions.Add(new SortDescription("PublishDate",
                                                                   ListSortDirection.Descending));

            NewFeedCommand = new RelayCommand(param => NewFeed());
            ModifyFeedCommand = new RelayCommand(param => ModifyFeed());
            ClearFeedItemsFilterCommand = new RelayCommand(param => ClearFeedItemsFilter());

            repo.FeedAdded += HandleFeedAdded;
            repo.FeedModified += HandleFeedModified;
            repo.FeedDeleted += HandleFeedDeleted;
            repo.FeedItemsAdded += HandleFeedItemsAdded;

            FeedsView.MoveCurrentTo(null);
        }
        public void AllFeeds_ReturnsAllFeeds()
        {
            context.Feeds.Add(new Feed { Title = "test feed 1", Url = "url" });
            context.Feeds.Add(new Feed { Title = "test feed 2", Url = "url" });
            context.Feeds.Add(new Feed { Title = "test feed 3", Url = "url" });
            context.SaveChanges();

            DataRepository underTest = new DataRepository(context);

            List<Feed> returnedFeeds = new List<Feed>(underTest.AllFeeds());

            Assert.AreEqual(context.Feeds.Count(), returnedFeeds.Count(),
                            "Returned AllFeeds collection is the wrong length.");

            Assert.Contains(context.Feeds.Single(f => f.Title == "test feed 1"), returnedFeeds);
            Assert.Contains(context.Feeds.Single(f => f.Title == "test feed 2"), returnedFeeds);
            Assert.Contains(context.Feeds.Single(f => f.Title == "test feed 3"), returnedFeeds);
        }