GetSortedCandidates() public method

Gets all SelectionCandidates for a specific set of Requirements sorted from best to worst.
public GetSortedCandidates ( [ requirements ) : IList
requirements [
return IList
Esempio n. 1
0
        public void TestGetSortedCandidates()
        {
            var mainFeed = FeedTest.CreateTestFeed();

            mainFeed.Feeds.Clear();
            _feedManagerMock.Setup(x => x[FeedTest.Test1Uri]).Returns(mainFeed);
            _packageManagerMock.Setup(x => x.Query((PackageImplementation)mainFeed.Elements[1])).Returns(Enumerable.Empty <ExternalImplementation>());

            var requirements = new Requirements(FeedTest.Test1Uri, Command.NameRun);

            _provider.GetSortedCandidates(requirements).Should().Equal(
                new SelectionCandidate(FeedTest.Test1Uri, new FeedPreferences(), (Implementation)mainFeed.Elements[0], requirements));
        }
Esempio n. 2
0
            /// <summary>
            /// Try to satisfy a set of <paramref name="requirements"/>, respecting any existing <see cref="Selections"/>.
            /// </summary>
            private bool TryToSolve([NotNull] Requirements requirements)
            {
                _cancellationToken.ThrowIfCancellationRequested();

                var allCandidates      = _candidateProvider.GetSortedCandidates(requirements);
                var suitableCandidates = FilterSuitableCandidates(allCandidates, requirements.InterfaceUri);
                var existingSelection  = Selections.GetImplementation(requirements.InterfaceUri);

                if (existingSelection == null)
                {
                    return(TryToSelectCandidate(suitableCandidates, requirements, allCandidates));
                }
                else if (TryToUseExistingCandidate(requirements, suitableCandidates, existingSelection))
                {
                    return(true);
                }
                else
                {
                    throw new SolverException("Dependency graph too complex");
                }
            }