Exemplo n.º 1
0
        public void SearchForDetailsReturnsMatchingEntries()
        {
            // Arrange
            var searcher = new EntrySearcher( ProjectListVm );

            // Act
            searcher.Text = "details:det";

            // Assert
            Assert.AreEqual( 1, searcher.Matches.Count );
            Assert.AreSame( Todos[1], searcher.Matches.First().Model );
        }
Exemplo n.º 2
0
        public void CurrentProjectIsChangedOnMessage()
        {
            // Arrange
            var messenger = new Messenger();

            var projectListMock = new Mock<IProjectListViewModel>();
            projectListMock.SetupGet( x => x.CurrentProject ).Verifiable();

            var searcher = new EntrySearcher( projectListMock.Object, messenger );

            // Act
            messenger.Send( new CurrentProjectChangedMessage( null ) );

            // Assert
            projectListMock.VerifyGet( x => x.CurrentProject, Times.Exactly( 2 ) );
        }
Exemplo n.º 3
0
        public void IsSearchingPropertyIsCorrectlySet()
        {
            // Arrange
            var projectListMock = new Mock<IProjectListViewModel>();
            var searcher = new EntrySearcher( projectListMock.Object );

            // Act
            searcher.Text = string.Empty;
            bool empty = searcher.IsSearching;

            searcher.Text = "test";
            bool nonEmpty = searcher.IsSearching;

            // Assert
            Assert.IsFalse( empty );
            Assert.IsTrue( nonEmpty );
        }
Exemplo n.º 4
0
        public MainViewModel(IDatabaseConnector connector, IViewServiceRepository viewServices = null, ITaskRunner taskRunner = null,
                             IProcessStarter procStarter      = null, IMessenger messenger = null, IProjectListViewModel projectList = null,
                             ISettingsRepository settingsRepo = null)
            : base(viewServices, settingsRepo, messenger)
        {
            var dbConnector = connector ?? Application.Current as IDatabaseConnector;

            Debug.Assert(dbConnector != null);

            var runner = taskRunner ?? new TaskRunner();

            ProcStarter = procStarter ?? new ProcessStarter();

            IsLoading = true;
            runner.Run(() =>
            {
                dbConnector.ConnectToDatabase();

                ProjectList = projectList ?? new ProjectListViewModel(ViewServices, Settings);
                TagList     = new TagListViewModel(ProjectList);
                Searcher    = new EntrySearcher(ProjectList);
            }).ContinueWith(t =>
            {
                ExpandEntries = Settings.GetById(SettingKeys.ExpandEntries).Get <bool>();

                // ReSharper disable ExplicitCallerInfoArgument
                RaisePropertyChanged(nameof(ProjectList));
                RaisePropertyChanged(nameof(TagList));
                RaisePropertyChanged(nameof(Searcher));
                // ReSharper restore ExplicitCallerInfoArgument

                IsLoading = false;

                CommandManager.InvalidateRequerySuggested();
            });
        }