Пример #1
0
        public void WhenRepositoryIsRestarted_ShouldCreateNewIntervalOnActiveTask()
        {
            var task = new Task {
                IsActive = true
            };

            task.Intervals.Add(new Interval());
            var tasks = new ObservableCollection <Task> {
                task
            };

            _repositoryMock.Setup(mock => mock.GetOpenTasks()).Returns(tasks);

            LifetimeDefinition lifetimeDefinition = Lifetimes.Define("Test.lifetime");
            var viewModel = new TaskViewModel(_repositoryMock.Object, lifetimeDefinition.Lifetime, _settingsRepoMock.Object);

            viewModel.AddTask(task);
            viewModel.ActivateTask(task);

            lifetimeDefinition.Terminate();

            Assert.AreEqual(1, task.Intervals.Count);

            var viewModel2 = new TaskViewModel(_repositoryMock.Object, Lifetimes.Define("Test.lifetime").Lifetime,
                                               _settingsRepoMock.Object);
            var activeTask = viewModel2.ActiveTask;

            Assert.AreEqual(2, activeTask.Intervals.Count);
            Assert.IsTrue(activeTask.Intervals[1].IsActive);
        }
Пример #2
0
        private void Activate_Click(object sender, RoutedEventArgs e)
        {
            var selectedTask = OpenTasksCombo.SelectedItem as Task;

            if (selectedTask != null)
            {
                _viewModel.ActivateTask(selectedTask);
            }
        }
Пример #3
0
        public void WhenActiveTaskExists_ShouldDisplayTimeSpan()
        {
            _task.Intervals.Add(new Interval
            {
                StartTime = DateTimeOffset.Now.AddMinutes(-10),
                EndTime   = DateTimeOffset.Now
            });
            _viewModel.ActivateTask(_task);

            Assert.AreEqual("Active Time: 10 minutes", _window.ActiveTime.Text);
        }
Пример #4
0
        public void WhenTaskIsPaused_FiresTaskPauseEvent()
        {
            var task = new Task();

            _repositoryMock.Setup(mock => mock.GetOpenTasks()).Returns(new ObservableCollection <Task>());

            LifetimeDefinition lifetimeDefinition = Lifetimes.Define("Test.lifetime");
            var viewModel = new TaskViewModel(_repositoryMock.Object, lifetimeDefinition.Lifetime, _settingsRepoMock.Object);

            viewModel.TaskChange += OnReceiveEvent;
            viewModel.ActivateTask(task);
            viewModel.OpenTask(task);

            Assert.AreEqual(TaskAction.Pause, _eventArgs.Action);
        }
Пример #5
0
        public void WhenLifetimeIsTerminated_ShouldCloseActiveTask()
        {
            var activeTask = new Task {
                IsActive = true
            };

            activeTask.Intervals.Add(new Interval());
            var tasks = new ObservableCollection <Task> {
                activeTask
            };

            _repositoryMock.Setup(mock => mock.GetOpenTasks()).Returns(tasks);

            LifetimeDefinition lifetimeDefinition = Lifetimes.Define("Test.lifetime");
            var viewModel = new TaskViewModel(_repositoryMock.Object, lifetimeDefinition.Lifetime, _settingsRepoMock.Object);

            viewModel.ActivateTask(activeTask);

            lifetimeDefinition.Terminate();

            var interval = activeTask.Intervals[0];

            Assert.IsTrue(interval.IsClosed);
        }
Пример #6
0
        private void MenuItemClicked(object sender, string name)
        {
            switch (name)
            {
            case "MenuItemAdd":
                OnCreateTaskRequested();
                break;

            case "MenuItemMoveUp":
                _taskViewModel.IncreasePriority(_selectedTask);
                break;

            case "MenuItemMoveDown":
                _taskViewModel.DecreasePriority(_selectedTask);
                break;

            case "MenuItemMoveLeft":
                Task newParent = _selectedTask.Parent.Parent;
                _taskViewModel.MoveSubtask(_selectedTask, newParent);
                break;

            case "MenuItemMoveRight":
                MoveRightTask(_selectedTask);
                break;

            case "MenuItemOpen":
                _taskViewModel.OpenTask(_selectedTask);
                break;

            case "MenuItemClose":
                _taskViewModel.CompleteTask(_selectedTask);
                break;

            case "MenuItemActivate":
                _taskViewModel.ActivateTask(_selectedTask);
                break;

            case "MenuItemPause":
                _taskViewModel.OpenTask(_selectedTask);
                break;

            case "MenuItemEdit":
                InsertAndShowControl(new TaskEditControl(_taskViewModel, _selectedTask));
                break;

            case "MenuItemDelete":
                _taskViewModel.RemoveTask(_selectedTask);
                break;

            case "MenuItemShowActive":
                var actionManager = Shell.Instance.GetComponent <IActionManager>();
                actionManager.ExecuteActionGuarded <ActiveTaskWindowAction>(_lifetime);
                break;

            case "MenuItemAddSubTask":
                InsertAndShowControl(new TaskEditControl(_taskViewModel, _selectedTask, true));
                break;

            case "Backward":
                NavigateBackward();
                break;

            case "Forward":
                NavigateForward();
                break;

            case "MenuItemIconMenu":
                ShowMenuSettingsMenu();
                break;

            default:
                break;
            }
        }