public LocalPackageSolutionDetailControlModelTests(GlobalServiceProvider sp, LocalPackageSearchMetadataFixture testData) : base(sp, testData) { var solMgr = new Mock <INuGetSolutionManagerService>(); var serviceBroker = new Mock <IServiceBroker>(); var projectManagerService = new Mock <INuGetProjectManagerService>(); projectManagerService.Setup(x => x.GetProjectsAsync(It.IsAny <CancellationToken>())).ReturnsAsync(new List <IProjectContextInfo>()); #pragma warning disable ISB001 // Dispose of proxies serviceBroker.Setup(x => x.GetProxyAsync <INuGetProjectManagerService>(It.Is <ServiceJsonRpcDescriptor>(d => d.Moniker == NuGetServices.ProjectManagerService.Moniker), It.IsAny <ServiceActivationOptions>(), It.IsAny <CancellationToken>())) .ReturnsAsync(projectManagerService.Object); #pragma warning restore ISB001 // Dispose of proxies NuGetUIThreadHelper.JoinableTaskFactory.Run(async() => { _testInstance = await PackageSolutionDetailControlModel.CreateAsync( solutionManager: solMgr.Object, projects: new List <IProjectContextInfo>(), serviceBroker: serviceBroker.Object, CancellationToken.None); }); _testInstance.SetCurrentPackageAsync( _testViewModel, ItemFilter.All, () => null).Wait(); }
public V3PackageSolutionDetailControlModelTests(GlobalServiceProvider sp, V3PackageSearchMetadataFixture testData) : base(sp, testData) { var packageSearchMetadata = new List <PackageSearchMetadataContextInfo>() { PackageSearchMetadataContextInfo.Create(_testData.TestData) }; var mockSearchService = new Mock <INuGetSearchService>(); mockSearchService.Setup(x => x.GetPackageMetadataListAsync( It.IsAny <string>(), It.IsAny <IReadOnlyCollection <PackageSourceContextInfo> >(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <CancellationToken>())) .Returns(new ValueTask <IReadOnlyCollection <PackageSearchMetadataContextInfo> >(packageSearchMetadata)); mockSearchService.Setup(x => x.GetDeprecationMetadataAsync( It.IsAny <PackageIdentity>(), It.IsAny <IReadOnlyCollection <PackageSourceContextInfo> >(), It.IsAny <bool>(), It.IsAny <CancellationToken>())) .Returns(null); mockSearchService.Setup(x => x.GetPackageMetadataAsync( It.IsAny <PackageIdentity>(), It.IsAny <IReadOnlyCollection <PackageSourceContextInfo> >(), It.IsAny <bool>(), It.IsAny <CancellationToken>())) .Returns(new ValueTask <(PackageSearchMetadataContextInfo, PackageDeprecationMetadataContextInfo)>((packageSearchMetadata[0], null))); var solMgr = new Mock <INuGetSolutionManagerService>(); var serviceBroker = new Mock <IServiceBroker>(); var projectManagerService = new Mock <INuGetProjectManagerService>(); projectManagerService.Setup(x => x.GetProjectsAsync(It.IsAny <CancellationToken>())).ReturnsAsync(new List <IProjectContextInfo>()); #pragma warning disable ISB001 // Dispose of proxies serviceBroker.Setup(x => x.GetProxyAsync <INuGetProjectManagerService>(It.Is <ServiceJsonRpcDescriptor>(d => d.Moniker == NuGetServices.ProjectManagerService.Moniker), It.IsAny <ServiceActivationOptions>(), It.IsAny <CancellationToken>())) .ReturnsAsync(projectManagerService.Object); serviceBroker.Setup( x => x.GetProxyAsync <INuGetSearchService>( NuGetServices.SearchService, It.IsAny <ServiceActivationOptions>(), It.IsAny <CancellationToken>())) .Returns(new ValueTask <INuGetSearchService>(mockSearchService.Object)); #pragma warning restore ISB001 // Dispose of proxies NuGetUIThreadHelper.JoinableTaskFactory.Run(async() => { _testInstance = await PackageSolutionDetailControlModel.CreateAsync( solutionManager: solMgr.Object, projects: new List <IProjectContextInfo>(), serviceBroker: serviceBroker.Object, CancellationToken.None); await _testInstance.SetCurrentPackageAsync( _testViewModel, ItemFilter.All, () => null); }); }