public void LicensePageButtons()
        {
            using (var thread = new TemporaryDispatcherThread())
            {
                var package = PackageFactory.Create("installable");
                this.PackageManager.RemotePackages.Add(package);

                ButtonBarViewModel buttonBarViewModel = this.CreateViewModel(thread);
                this.SelectPackage(thread, buttonBarViewModel.NuGetViewModel, Resources.Filter_All, package.Id);

                Assert.True(buttonBarViewModel.InstallButton.Command.CanExecute(PackageViewModelAction.InstallOrUninstall));
                thread.Invoke(() => { buttonBarViewModel.InstallButton.Command.Execute(PackageViewModelAction.InstallOrUninstall); });
                buttonBarViewModel.NuGetViewModel.WaitUntilComplete();

                Assert.True(buttonBarViewModel.YesButton.Command.CanExecute(null));
                thread.Invoke(() => { buttonBarViewModel.YesButton.Command.Execute(null); });
                buttonBarViewModel.NuGetViewModel.WaitUntilComplete();

                Assert.Equal(
                    new ButtonViewModel[] { buttonBarViewModel.AcceptButton, buttonBarViewModel.DeclineButton },
                    buttonBarViewModel.ActionButtons);
            }
        }
Пример #2
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.");
            }
        }
        /// <summary>
        /// Creates a NuGetViewModel and ButtonBarViewModel for testing
        /// </summary>
        private ButtonBarViewModel CreateViewModel(TemporaryDispatcherThread thread)
        {
            ButtonBarViewModel buttonBarViewModel = null;
            NuGetViewModel     nuGetViewModel     = null;

            thread.Invoke(() =>
            {
                nuGetViewModel = new NuGetViewModel(
                    this.Descriptor.Object,
                    this.Host.Object,
                    this.PackageSourcesViewModel,
                    (uri, site) => this.PackageManager,
                    this.ReadonlyDestination,
                    thread.Scheduler);

                buttonBarViewModel = new ButtonBarViewModel(nuGetViewModel, this.CloseCommand);
            });
            nuGetViewModel.WaitUntilComplete();

            return(buttonBarViewModel);
        }