コード例 #1
0
        public void NewHistoryIsEmpty()
        {
            var history = new RuntimeSearchHistory();

            var entries = history.SearchedTerms();

            Assert.Empty(entries);
        }
コード例 #2
0
        public void AddingEntryToHistoryWillYieldThisEntry()
        {
            var          history      = new RuntimeSearchHistory();
            const string expectedTerm = "anything";

            history.AddEntry(expectedTerm);

            var entries = history.SearchedTerms();

            Assert.Contains(entries, e => e.Equals(expectedTerm, StringComparison.Ordinal));
        }
コード例 #3
0
        public void RemovingTermThatIsNotInListDoesNothing()
        {
            var          history  = new RuntimeSearchHistory();
            const string anything = nameof(anything);

            history.RemoveEntry(anything);

            var entries = history.SearchedTerms();

            Assert.Empty(entries);
        }
コード例 #4
0
        public void TwiceAddedTermIsYieldedOnlyOnce()
        {
            var          history      = new RuntimeSearchHistory();
            const string expectedTerm = "anything";

            history.AddEntry(expectedTerm);
            history.AddEntry(expectedTerm);

            var entries = history.SearchedTerms();

            Assert.Single(entries);
        }
コード例 #5
0
        public void RemovedTermIsNotYielded()
        {
            var          history      = new RuntimeSearchHistory();
            const string expectedTerm = "anything";

            history.AddEntry(expectedTerm);
            history.RemoveEntry(expectedTerm);

            var entries = history.SearchedTerms();

            Assert.Empty(entries);
        }
コード例 #6
0
        public void ManuallyGivenDateIsRespected()
        {
            var          history = new RuntimeSearchHistory();
            const string oldTerm = nameof(oldTerm);
            const string newTerm = nameof(newTerm);

            history.AddEntry(oldTerm, DateTime.Now + TimeSpan.FromHours(1));
            history.AddEntry(newTerm);
            var inOrder = new[] { oldTerm, newTerm };

            var entries = history.SearchedTerms();

            Assert.Equal(inOrder, entries);
        }
コード例 #7
0
        public void EntriesAreSortedByDateDescending()
        {
            var          history = new RuntimeSearchHistory();
            const string oldTerm = nameof(oldTerm);
            const string newTerm = nameof(newTerm);

            history.AddEntry(oldTerm);
            history.AddEntry(newTerm);
            var inOrder = new[] { newTerm, oldTerm };

            var entries = history.SearchedTerms();

            Assert.Equal(inOrder, entries);
        }
コード例 #8
0
        public void EntryAddedAgainWillUpdateItsUsedTime()
        {
            var          history = new RuntimeSearchHistory();
            const string oldTerm = nameof(oldTerm);
            const string newTerm = nameof(newTerm);

            history.AddEntry(oldTerm);
            history.AddEntry(newTerm);
            history.AddEntry(oldTerm);

            var newestEntry = history.SearchedTerms().First();

            Assert.Equal(oldTerm, newestEntry);
        }
コード例 #9
0
        public void AddingEntriesToHistoryWillYieldTheseEntries()
        {
            var history       = new RuntimeSearchHistory();
            var expectedTerms = new[] { "term1", "term2" };

            foreach (var term in expectedTerms)
            {
                history.AddEntry(term);
            }

            var entries = history.SearchedTerms();

            Assert.Equal(expectedTerms.Reverse(), entries.ToArray());
        }
コード例 #10
0
        public CoreSetup(IPathResolver pathResolver, IDistributedNotificationReceiver?notificationReceiver, IDispatcher uiDispatcher)
        {
            _pathResolver = pathResolver;
            var serializer = new Serializer();

            var pluginHost   = new PluginHost(uiDispatcher);
            var pluginLoader = new PluginLoader(pluginHost);

            PluginRepository = pluginLoader.LoadPlugins(pathResolver.PluginFolders);

            _configurationSerializer = new ConfigurationSerializer(serializer);
            ConfigurationBuilder     = new ConfigurationBuilder(_pathResolver, _configurationSerializer);
            Configuration            = ConfigurationBuilder.LoadConfiguration();

            ProjectProvider = new ProjectProvider(Configuration, PluginRepository);

            UserIdentityList = new UserIdentityList();

            var treeBuilder = new TreeBuilder(Configuration);

            Pipeline = new Pipeline.Pipeline(treeBuilder, Configuration, UserIdentityList);

            Pipeline.Notifier.Updated += Notifier_Updated;

            SearchEngine = new SearchEngine();
            SearchEngine.AddCriteria(new BranchCriteria(Pipeline));
            SearchEngine.AddCriteria(new DefinitionCriteria(Pipeline));
            SearchEngine.AddCriteria(new IsCriteria(Pipeline));
            SearchEngine.AddCriteria(new ForCriteria(Pipeline));
            SearchEngine.AddCriteria(new ByCriteria(Pipeline));
            SearchEngine.AddCriteria(new DuringCriteria(Pipeline));
            SearchEngine.AddCriteria(new AfterCriteria(Pipeline), false);
            SearchEngine.AddCriteria(new BeforeCriteria(Pipeline), false);

            SearchHistory = new RuntimeSearchHistory();

            if (notificationReceiver != null)
            {
                NotificationReceiver = notificationReceiver;
                NotificationReceiver.DistributedNotificationReceived += (sender, args) => DistributedNotificationReceived?.Invoke(this, args);
            }
        }