Ejemplo n.º 1
0
            public void TaskCancelledEvent()
            {
                var taskId = Guid.NewGuid();
                var e      = new TaskCancelledEvent()
                {
                    DateOfCancellation = DateTime.Now,
                    TaskId             = taskId
                };
                var task = OTask.Factory.Create(taskId, "Fake");

                task.ApplyEvent(e);
                Assert.Equal(e.DateOfCancellation, task.DateOfCancellation);
            }
Ejemplo n.º 2
0
        public void Cancel(Guid userId)
        {
            if (userId != this.CreatorId)
            {
                throw new ArgumentException("A task can be cancelled by its creator only", nameof(userId));
            }
            if (this.DateOfCompletion.HasValue)
            {
                throw new InvalidOperationException("Can't cancel a closed task.");
            }
            if (this.DateOfCancellation.HasValue)
            {
                throw new InvalidOperationException("Can't cancel a task twice.");
            }

            var e = new TaskCancelledEvent()
            {
                TaskId             = this.Id,
                DateOfCancellation = DateTime.Now,
                UserId             = userId
            };

            RaiseEvent(e);
        }
Ejemplo n.º 3
0
 public void ApplyEvent(TaskCancelledEvent @event)
 {
     this.DateOfCancellation = @event.DateOfCancellation;
 }