public VsPathContextProviderTests(DispatcherThreadFixture fixture)
        {
            Assumes.Present(fixture);

            _jtf = fixture.JoinableTaskFactory;
            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_jtf);
        }
예제 #2
0
        protected override void OnStartup(System.Windows.StartupEventArgs e)
        {
            base.OnStartup(e);

            var mainThread             = Thread.CurrentThread;
            var synchronizationContext = SynchronizationContext.Current;

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(mainThread, synchronizationContext);

            var sp = new ServiceProvider();

            ServiceLocator.InitializePackageServiceProvider(sp);

            var host = sp.HostProvider?.CreateHost(async: false);

            host.ActivePackageSource = "All";
            var commandExpansion = sp.CommandExpansionProvider?.Create(host);

            var console = new StandaloneConsole();

            host.Initialize(console);

            Task.Run(async() =>
            {
                var listener = new ConsoleListener(host, commandExpansion);
                await listener.RunAsync(console).ConfigureAwait(false);
            });
        }
예제 #3
0
        public CpsPackageReferenceProjectProviderTests(DispatcherThreadFixture fixture)
        {
            Assumes.Present(fixture);

            _jtf = fixture.JoinableTaskFactory;

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_jtf);
        }
예제 #4
0
        public InfiniteScrollListTests()
        {
#pragma warning disable VSSDK005 // Avoid instantiating JoinableTaskContext
            _joinableTaskContext = new JoinableTaskContext(Thread.CurrentThread, SynchronizationContext.Current);
#pragma warning restore VSSDK005 // Avoid instantiating JoinableTaskContext

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_joinableTaskContext.Factory);
        }
예제 #5
0
        public ProjectKNuGetProjectTests(DispatcherThreadFixture fixture)
        {
            Assumes.Present(fixture);

            _jtf = fixture.JoinableTaskFactory;

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_jtf);
        }
예제 #6
0
        public NuGetLockServiceTests(DispatcherThreadFixture fixture)
        {
            Assumes.Present(fixture);

            _jtf = fixture.JoinableTaskFactory;

            _lockService = new NuGetLockService(fixture.JoinableTaskFactory.Context);
            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_jtf);
            Assert.False(_lockService.IsLockHeld);
        }
예제 #7
0
        public NuGetUITests()
        {
#pragma warning disable VSSDK005 // Avoid instantiating JoinableTaskContext
            _joinableTaskContext = new JoinableTaskContext(Thread.CurrentThread, SynchronizationContext.Current);
#pragma warning restore VSSDK005 // Avoid instantiating JoinableTaskContext

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_joinableTaskContext.Factory);

            _testDirectory = TestDirectory.Create();
        }
예제 #8
0
        public SolutionRestoreBuildHandlerTests(DispatcherThreadFixture fixture)
        {
            Assumes.Present(fixture);

            _jtf = fixture.JoinableTaskFactory;

#pragma warning disable VSSDK005 // Avoid instantiating JoinableTaskContext
            var joinableTaskContext = new JoinableTaskContext(Thread.CurrentThread, SynchronizationContext.Current);
#pragma warning restore VSSDK005 // Avoid instantiating JoinableTaskContext

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_jtf);
        }
예제 #9
0
        public NuGetProjectManagerServiceTests(DispatcherThreadFixture dispatcherThreadFixture)
        {
            Assert.NotNull(dispatcherThreadFixture);

            _projectContext = new TestNuGetProjectContext();
            _services       = new Dictionary <Type, Task <object> >()
            {
                { typeof(INuGetProjectContext), Task.FromResult <object>(_projectContext) }
            };

            ServiceLocator.InitializePackageServiceProvider(this);

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(dispatcherThreadFixture.JoinableTaskFactory);
        }
        public PackageItemListViewModelTests(DispatcherThreadFixture fixture, ITestOutputHelper output, LocalPackageSearchMetadataFixture testData)
        {
            _testData     = testData;
            _testInstance = new PackageItemListViewModel()
            {
                PackageReader = _testData.TestData.PackageReader,
            };
            _output = output;

            Assumes.Present(fixture);

            _jtf = fixture.JoinableTaskFactory;
            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_jtf);
        }
예제 #11
0
        private void CreatePackageManagerControl()
        {
            _container = Initialize();

            // This method is called from MainWindow's constructor. Current thread is the main thread
            var mainThread             = Thread.CurrentThread;
            var synchronizationContext = SynchronizationContext.Current;

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(mainThread, synchronizationContext);

            Title  = "NuGet Standalone UI";
            Height = 800;
            Width  = 1000;

            var repositoryProvider = new SourceRepositoryProvider(_settings, Repository.Provider.GetVisualStudio());
            var settings           = new DefaultSettings();

            var testSolutionManager = new TestSolutionManager(@"c:\temp\test");

            var projectA = testSolutionManager.AddNewMSBuildProject("projectA");
            //var projectB = testSolutionManager.AddNewMSBuildProject("projectB");
            //var projectC = testSolutionManager.AddProjectKProject("projectK");
            var projectBuildIntegrated = testSolutionManager.AddBuildIntegratedProject("BuildIntProj", NuGetFramework.Parse("net46"));

            var projects = new[] { projectBuildIntegrated };

            var packageRestoreManager = new PackageRestoreManager(
                repositoryProvider,
                settings,
                testSolutionManager);

            var contextFactory = new StandaloneUIContextFactory(
                repositoryProvider,
                testSolutionManager,
                settings,
                packageRestoreManager: packageRestoreManager,
                optionsPage: null);
            var context      = contextFactory.Create(@"c:\temp\test\settings.txt", projects);
            var uiController = _uiServiceFactory.Create(
                context,
                new NuGetUIProjectContext(new StandaloneUILogger(_textBox, _scrollViewer), _sourceControlManagerProvider, _commonOperations));

            var model = new PackageManagerModel(uiController, context, isSolution: false, editorFactoryGuid: Guid.Empty);

            model.SolutionName     = "test solution";
            _packageManagerControl =
                new PackageManagerControl(model, _settings, new SimpleSearchBoxFactory(), vsShell: null);
            layoutGrid.Children.Add(_packageManagerControl);
        }
        public DetailControlModelTestBase(LocalPackageSearchMetadataFixture testData)
        {
            _testData = testData;
            var testVersion = new NuGetVersion(0, 0, 1);

            _testViewModel = new PackageItemListViewModel()
            {
                PackageReader    = _testData.TestData.PackageReader,
                Version          = testVersion,
                InstalledVersion = testVersion,
            };

#pragma warning disable VSSDK005 // Avoid instantiating JoinableTaskContext
            _joinableTaskContext = new JoinableTaskContext(Thread.CurrentThread, SynchronizationContext.Current);
#pragma warning restore VSSDK005 // Avoid instantiating JoinableTaskContext
            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_joinableTaskContext.Factory);
        }
예제 #13
0
        public V3DetailControlModelTestBase(V3PackageSearchMetadataFixture testData)
        {
            _testData = testData;

            // The versions pre-baked into the view model provide data for the first step of metadata extraction
            // which fails (null) in a V3 scenario--they need to be extracted using a metadata provider (below)
            var testVersion  = new NuGetVersion(0, 0, 1);
            var testVersions = new List <VersionInfo>()
            {
                new VersionInfo(new NuGetVersion(0, 0, 1)),
                new VersionInfo(new NuGetVersion(0, 0, 2))
            };

            _testViewModel = new PackageItemListViewModel()
            {
                Version          = testVersion,
                Versions         = new Lazy <Task <IEnumerable <VersionInfo> > >(() => Task.FromResult <IEnumerable <VersionInfo> >(testVersions)),
                InstalledVersion = testVersion,
            };

            var resourceProvider = new MockNuGetResourceProvider();
            var metadataResource = new MockPackageMetadataResource(_testData.TestData);
            var repository       = new MockSourceRepository <PackageMetadataResource>(
                new PackageSource("nuget.psm.test"),
                new List <INuGetResourceProvider>()
            {
                resourceProvider
            },
                metadataResource);
            var repositories = new List <SourceRepository>()
            {
                repository
            };

            _metadataProvider = new MultiSourcePackageMetadataProvider(
                repositories,
                optionalLocalRepository: null,
                optionalGlobalLocalRepositories: null,
                logger: new Mock <ILogger>().Object);

#pragma warning disable VSSDK005 // Avoid instantiating JoinableTaskContext
            _joinableTaskContext = new JoinableTaskContext(Thread.CurrentThread, SynchronizationContext.Current);
#pragma warning restore VSSDK005 // Avoid instantiating JoinableTaskContext
            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(_joinableTaskContext.Factory);
        }
예제 #14
0
        public InfiniteScrollListTests()
        {
            var joinableTaskContext = new JoinableTaskContext(Thread.CurrentThread, SynchronizationContext.Current);

            NuGetUIThreadHelper.SetCustomJoinableTaskFactory(joinableTaskContext.Factory);
        }
예제 #15
0
 public NuGetFeatureFlagServiceTests(GlobalServiceProvider sp)
 {
     sp.Reset();
     _globalProvider = sp;
     NuGetUIThreadHelper.SetCustomJoinableTaskFactory(ThreadHelper.JoinableTaskFactory);
 }
예제 #16
0
 public UIActionEngineTests(GlobalServiceProvider sp)
 {
     sp.Reset();
     NuGetUIThreadHelper.SetCustomJoinableTaskFactory(ThreadHelper.JoinableTaskFactory);
 }