Beispiel #1
0
        public void CreateViewModel()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource = new FeedSource("http://oo.com", "test source");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);
                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.False(viewModel.Loading, "The view model should be done loading");
                Assert.Equal<FeedSource>(feedSource, viewModel.SelectedFeedSource);
            }
        }
Beispiel #2
0
        public void SelectedFeedSourceUsed()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource      = new FeedSource("http://oo.com", "test source");
                var sources         = new FeedSource[] { new FeedSource("http://fake.com", "this shouldn't be selected"), feedSource };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));

                viewModel.WaitUntilComplete();

                Assert.Equal <FeedSource>(packageSourcesViewModel.ActiveFeedSource, viewModel.SelectedFeedSource);
            }
        }
Beispiel #3
0
        public void FirstFilterSelected()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource      = new FeedSource("http://oo.com", "test source");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() => {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));

                viewModel.WaitUntilComplete();

                Assert.Equal <IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter);
            }
        }
Beispiel #4
0
        public void CreateViewModel()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource              = new FeedSource("http://oo.com", "test source");
                var feedSourceStore         = new InMemoryFeedSourceStore(feedSource);
                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.False(viewModel.Loading, "The view model should be done loading");
                Assert.Equal <FeedSource>(feedSource, viewModel.SelectedFeedSource);
            }
        }
Beispiel #5
0
        public void SelectPrereleaseFilter()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource              = new FeedSource("http://oo.com", "test source");
                var feedSourceStore         = new InMemoryFeedSourceStore(feedSource);
                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal <string>(Resources.Prerelease_Filter_StableOnly, viewModel.SelectedPrereleaseFilter);

                viewModel.SelectedPrereleaseFilter = Resources.Prerelease_Filter_IncludePrerelease;
                Assert.Equal <string>(Resources.Prerelease_Filter_IncludePrerelease, viewModel.SelectedPrereleaseFilter);
            }
        }
Beispiel #6
0
        public void SourceWithPackages()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource      = new FeedSource("http://1.com", "source1");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();
                packageManager.RemotePackages.Add(PackageFactory.Create("package1"));

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.True(viewModel.Filters.Any(f => f.Count > 0), "One of the filters should have some items");
            }
        }
Beispiel #7
0
        public void SelectAnotherFilter()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource1     = new FeedSource("http://1.com", "source1");
                var feedSource2     = new FeedSource("http://2.com", "source2");
                var sources         = new FeedSource[] { feedSource1, feedSource2 };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.True(viewModel.Filters.Count >= 2, "This test needs at least 2 filters");
                Assert.Equal <IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter);

                viewModel.SelectedFilter = viewModel.Filters[1];
                Assert.Equal <IListViewFilter>(viewModel.Filters[1], viewModel.SelectedFilter);
            }
        }
Beispiel #8
0
        public void SelectedFeedSourceUsed()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource = new FeedSource("http://oo.com", "test source");
                var sources = new FeedSource[] { new FeedSource("http://fake.com", "this shouldn't be selected"), feedSource };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));

                viewModel.WaitUntilComplete();

                Assert.Equal<FeedSource>(packageSourcesViewModel.ActiveFeedSource, viewModel.SelectedFeedSource);
            }
        }
Beispiel #9
0
        public void SelectAnotherSourceHidesDetails()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource1     = new FeedSource("http://1.com", "source1");
                var feedSource2     = new FeedSource("http://2.com", "source2");
                var sources         = new FeedSource[] { feedSource1, feedSource2 };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore));

                var packageManager = new InMemoryPackageManager();
                packageManager.RemotePackages.Add(PackageFactory.Create("select me"));

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal <FeedSource>(feedSource1, viewModel.SelectedFeedSource);

                var firstFilter  = viewModel.Filters[0];
                var itemToSelect = firstFilter.FilteredItems.OfType <object>().First();
                thread.Invoke(() =>
                {
                    viewModel.SelectedItem = itemToSelect;

                    // show the details page
                    viewModel.IsDetailsPaneVisible = true;
                });

                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel.SelectedFeedSourceItem = feedSource2;
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal <FeedSource>(feedSource2, viewModel.SelectedFeedSource);
                Assert.False(viewModel.IsDetailsPaneVisible, "The details pane should be hidden now.");
            }
        }
Beispiel #10
0
        public void SelectAPackage()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource      = new FeedSource("http://1.com", "source1");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();
                packageManager.RemotePackages.Add(PackageFactory.Create("package1"));

                NuGetViewModel viewModel = null;
                thread.Invoke(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                });
                viewModel.WaitUntilComplete();

                var filterToSelect = viewModel.Filters.First(f => f.Count > 0);
                if (viewModel.SelectedFilter != filterToSelect)
                {
                    viewModel.SelectedFilter = filterToSelect;
                }

                Assert.Equal <IListViewFilter>(filterToSelect, viewModel.SelectedFilter);
                Assert.Null(viewModel.SelectedItem);

                var itemToSelect = filterToSelect.FilteredItems.OfType <object>().First();
                thread.Invoke(() => { viewModel.SelectedItem = itemToSelect; });
                Assert.Equal(itemToSelect, viewModel.SelectedItem);
                Assert.NotNull(itemToSelect);
            }
        }
Beispiel #11
0
        public void SelectAnotherSource()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource1     = new FeedSource("http://1.com", "source1");
                var feedSource2     = new FeedSource("http://2.com", "source2");
                var sources         = new FeedSource[] { feedSource1, feedSource2 };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal <FeedSource>(feedSource1, viewModel.SelectedFeedSource);

                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel.SelectedFeedSourceItem = feedSource2;
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal <FeedSource>(feedSource2, viewModel.SelectedFeedSource);
            }
        }
Beispiel #12
0
        public void SelectPrereleaseFilter()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource = new FeedSource("http://oo.com", "test source");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);
                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal<string>(Resources.Prerelease_Filter_StableOnly, viewModel.SelectedPrereleaseFilter);

                viewModel.SelectedPrereleaseFilter = Resources.Prerelease_Filter_IncludePrerelease;
                Assert.Equal<string>(Resources.Prerelease_Filter_IncludePrerelease, viewModel.SelectedPrereleaseFilter);
            }
        }
Beispiel #13
0
        public void SelectAPackage()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource = new FeedSource("http://1.com", "source1");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();
                packageManager.RemotePackages.Add(PackageFactory.Create("package1"));

                NuGetViewModel viewModel = null;
                thread.Invoke(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                });
                viewModel.WaitUntilComplete();

                var filterToSelect = viewModel.Filters.First(f => f.Count > 0);
                if (viewModel.SelectedFilter != filterToSelect)
                {
                    viewModel.SelectedFilter = filterToSelect;
                }

                Assert.Equal<IListViewFilter>(filterToSelect, viewModel.SelectedFilter);
                Assert.Null(viewModel.SelectedItem);

                var itemToSelect = filterToSelect.FilteredItems.OfType<object>().First();
                thread.Invoke(() => { viewModel.SelectedItem = itemToSelect; });
                Assert.Equal(itemToSelect, viewModel.SelectedItem);
                Assert.NotNull(itemToSelect);
            }
        }
Beispiel #14
0
        public void SourceWithPackages()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource = new FeedSource("http://1.com", "source1");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();
                packageManager.RemotePackages.Add(PackageFactory.Create("package1"));

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.True(viewModel.Filters.Any(f => f.Count > 0), "One of the filters should have some items");
            }
        }
Beispiel #15
0
        public void SelectAnotherFilterHidesDetails()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource1 = new FeedSource("http://1.com", "source1");
                var feedSource2 = new FeedSource("http://2.com", "source2");
                var sources = new FeedSource[] { feedSource1, feedSource2 };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore));

                var packageManager = new InMemoryPackageManager();
                packageManager.RemotePackages.Add(PackageFactory.Create("select me"));

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                var firstFilter = viewModel.Filters[0];
                Assert.True(viewModel.Filters.Count >= 2, "This test needs at least 2 filters");
                Assert.Equal<IListViewFilter>(firstFilter, viewModel.SelectedFilter);

                var itemToSelect = firstFilter.FilteredItems.OfType<object>().First();
                thread.Invoke(() => { 
                    viewModel.SelectedItem = itemToSelect;

                    // show the details page
                    viewModel.IsDetailsPaneVisible = true;
                });

                viewModel.SelectedFilter = viewModel.Filters[1];
                viewModel.WaitUntilComplete();
                Assert.Equal<IListViewFilter>(viewModel.Filters[1], viewModel.SelectedFilter);
                Assert.False(viewModel.IsDetailsPaneVisible, "The details page should be hidden");
            }
        }
Beispiel #16
0
        public void SelectAnotherFilter()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource1 = new FeedSource("http://1.com", "source1");
                var feedSource2 = new FeedSource("http://2.com", "source2");
                var sources = new FeedSource[] { feedSource1, feedSource2 };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.True(viewModel.Filters.Count >= 2, "This test needs at least 2 filters");
                Assert.Equal<IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter);

                viewModel.SelectedFilter = viewModel.Filters[1];
                Assert.Equal<IListViewFilter>(viewModel.Filters[1], viewModel.SelectedFilter);
            }
        }
Beispiel #17
0
        public void FirstFilterSelected()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource = new FeedSource("http://oo.com", "test source");
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() => {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));

                viewModel.WaitUntilComplete();

                Assert.Equal<IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter);
            }
        }
Beispiel #18
0
        public void SelectAnotherSource()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var feedSource1 = new FeedSource("http://1.com", "source1");
                var feedSource2 = new FeedSource("http://2.com", "source2");
                var sources = new FeedSource[] { feedSource1, feedSource2 };
                var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources);

                var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore));

                var packageManager = new InMemoryPackageManager();

                NuGetViewModel viewModel = null;
                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel = new NuGetViewModel(
                        this.Descriptor.Object,
                        this.Host.Object,
                        packageSourcesViewModel,
                        (uri, site) => packageManager,
                        this.ReadonlyDestination,
                        thread.Scheduler);
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal<FeedSource>(feedSource1, viewModel.SelectedFeedSource);

                thread.Dispatcher.Invoke((Action)(() =>
                {
                    viewModel.SelectedFeedSourceItem = feedSource2;
                }));
                viewModel.WaitUntilComplete();

                Assert.Equal<FeedSource>(feedSource2, viewModel.SelectedFeedSource);
            }
        }