public UpdatePackageFeedTests() { // dependencies and data _metadataResource = Mock.Of <PackageMetadataResource>(); var provider = Mock.Of <INuGetResourceProvider>(); Mock.Get(provider) .Setup(x => x.TryCreate(It.IsAny <SourceRepository>(), It.IsAny <CancellationToken>())) .Returns(() => Task.FromResult(Tuple.Create(true, (INuGetResource)_metadataResource))); Mock.Get(provider) .Setup(x => x.ResourceType) .Returns(typeof(PackageMetadataResource)); var logger = new TestLogger(); var packageSource = new Configuration.PackageSource("http://fake-source"); var source = new SourceRepository(packageSource, new[] { provider }); // target _metadataProvider = new MultiSourcePackageMetadataProvider( new[] { source }, optionalLocalRepository: null, optionalGlobalLocalRepositories: null, logger: logger); }
public NoLocalProviderTests() { _target = new MultiSourcePackageMetadataProvider( new[] { _source }, optionalLocalRepository: null, optionalGlobalLocalRepositories: null, logger: _logger); }
public void LoadPackageMetadata(PackageSearchResultViewModel packageViewModel) { var provider = new MultiSourcePackageMetadataProvider( selectedPackageSource.GetSourceRepositories(), packageManager.PackagesFolderSourceRepository, packageManager.GlobalPackagesFolderSourceRepository, new NuGet.Logging.NullLogger()); packageViewModel.LoadPackageMetadata(provider, cancellationTokenSource.Token); }
protected async Task <IPackageSearchMetadata> GetLatestPackageFromRemoteSourceAsync(PackageIdentity identity, bool includePrerelease) { var metadataProvider = new MultiSourcePackageMetadataProvider( PrimarySourceRepositories, optionalLocalRepository: null, optionalGlobalLocalRepositories: null, logger: Common.NullLogger.Instance); return(await metadataProvider.GetLatestPackageMetadataAsync(identity, Project, includePrerelease, Token)); }
protected async Task <IEnumerable <IPackageSearchMetadata> > GetPackagesFromRemoteSourceAsync(string packageId, bool includePrerelease) { var metadataProvider = new MultiSourcePackageMetadataProvider( PrimarySourceRepositories, optionalLocalRepository: null, optionalGlobalLocalRepositories: null, logger: Common.NullLogger.Instance); return(await metadataProvider.GetPackageMetadataListAsync( packageId, includePrerelease, includeUnlisted : false, cancellationToken : Token)); }
public LocalProviderTests() { _localMetadataResource = Mock.Of <PackageMetadataResource>(); _localSource = SetupSourceRepository(_localMetadataResource); _globalMetadataResource = Mock.Of <PackageMetadataResource>(); _globalSource = SetupSourceRepository(_globalMetadataResource); _target = new MultiSourcePackageMetadataProvider( new[] { _source }, optionalLocalRepository: _localSource, optionalGlobalLocalRepositories: new[] { _globalSource }, logger: _logger); }
protected async Task <IPackageSearchMetadata> GetLatestPackageFromRemoteSourceAsync( NuGetProject nugetProject, PackageIdentity identity, bool includePrerelease) { var metadataProvider = new MultiSourcePackageMetadataProvider( PrimarySourceRepositories, optionalLocalRepository: null, optionalGlobalLocalRepositories: null, projects: new [] { nugetProject }, isSolution: false, logger: NuGet.Common.NullLogger.Instance); return(await metadataProvider.GetLatestPackageMetadataAsync(identity, includePrerelease, ConsoleHost.Token)); }
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); }