コード例 #1
0
        /// <exception cref="UnknownPriorityException">Condition.</exception>
        /// <exception cref="TaskWithSameTitleExistsInProjectException">Condition.</exception>
        public void Handle(RegisterTask command)
        {
            var          title     = new Title(command.Title);
            var          projectId = new ProjectId(command.ProjectId);
            TaskPriority priority;

            if (!TaskPriority.TryParse(command.Priority, out priority))
            {
                throw new UnknownPriorityException(command.Priority);
            }

            Task task;

            if (command.Deadline.HasValue)
            {
                var deadline = new TaskDeadline(command.Deadline.Value);
                task = new Task(projectId, title, priority, deadline);
            }
            else
            {
                task = new Task(projectId, title, priority);
            }

            var  query = new DoesTaskWithTitleAlreadyExistUnderSameProjectQuery(title, projectId);
            bool taskWithSameTitleExists = _taskQueryHandler.Handle(query);

            if (taskWithSameTitleExists)
            {
                throw new TaskWithSameTitleExistsInProjectException();
            }

            _eventStoreRepository.Save(task);
        }
コード例 #2
0
        /// <exception cref="DeadlineIsInThePastException">Condition.</exception>
        public void Handle(ChangeDeadlineOnTask command)
        {
            Task task        = _eventStoreRepository.GetById(command.Id);
            var  newDeadline = new TaskDeadline(command.Deadine);

            task.ChangeDeadline(newDeadline);
            _eventStoreRepository.Save(task);
        }
コード例 #3
0
        public void Register_Task_With_Deadline_Can_Be_Saved_In_Event_Store()
        {
            var title    = new Title(Fixture.Create <string>());
            var deadline = new TaskDeadline(DateTime.UtcNow);
            var task     = new Task(_projectId, title, TaskPriority.Low, deadline);

            _eventStoreRepository.Save(task);

            Task taskFromEventStore = _eventStoreRepository.GetById(task.Id);

            Assert.That(taskFromEventStore, Is.Not.Null);
        }
コード例 #4
0
ファイル: SaveNoteTest.cs プロジェクト: SabrinaMH/TaskManager
        public void Task_With_Note_Can_Be_Saved_In_Event_Store()
        {
            var projectId = new ProjectId(Fixture.Create <string>());
            var title     = new Title(Fixture.Create <string>());
            var deadline  = new TaskDeadline(DateTime.UtcNow);
            var task      = new Task(projectId, title, TaskPriority.Low, deadline);

            task.SaveNote(new Note(Fixture.Create <string>()));
            var eventStoreRepository = new EventStoreRepository <Task>(EventBus, InMemoryEventStoreConnectionBuilder);

            eventStoreRepository.Save(task);

            Task taskFromEventStore = eventStoreRepository.GetById(task.Id);

            Assert.That(taskFromEventStore, Is.Not.Null);
        }