private static void create_task()
 {
     parent_task = TaskFactory.CreateTask(project, user, user, "PreNxt-父任务");
     first_task = TaskFactory.CreateTask(project, user, user, "PreNxt-首任务");
     center_task = TaskFactory.CreateTask(project, user, user, "PreNxt-中间任务");
     last_task = TaskFactory.CreateTask(project, user, user, "PreNxt-尾任务");
 }
Пример #2
0
        public void BeginWork()
        {
            Task task = new Task();

            task.BeginWork();

            task.has_begin();
        }
Пример #3
0
        public void BeginEdit()
        {
            Task task = new Task();
            User user_1 = new User();

            task.BeginEdit(user_1);
            Assert.That(task.EditingBy, Is.EqualTo(user_1));
        }
Пример #4
0
        public void EndEdit()
        {
            Task task = new Task();
            User user_1 = new User();

            task.BeginEdit(user_1);
            task.EndEdit();
            Assert.That(task.EditingBy, Is.Null);
        }
Пример #5
0
 public static void FilledBy(this LiteItemModel model, Task task)
 {
     model.Id = task.Id;
     model.Sequence = task.Sequence;
     model.Title = task.Title;
     model.CurrentStatus = new StatusModel();
     model.CurrentStatus.FilledBy(task.CurrentStatus);
     model.Virtual = task.IsVirtual;
     model.HasChild = !task.Children.IsNullOrEmpty();
     model.NodeType = task.NodeType;
 }
Пример #6
0
        public void Complete()
        {
            Task task = new Task { Accepter = new User(), ExpectCompleteTime = SystemTime.Now() };
            task.BeginWork();

            SystemTime.SetDateTime(now.AddHours(3));
            task.Complete();

            task.has_complete();
            Assert.That(task.Delay, Is.EqualTo(3));
        }
Пример #7
0
        public void Refused()
        {
            Task task = new Task
            {
                Project = new Project()
            };
            string comment = "accept comment";
            task.RefuseAccept();

            Assert.That(task.HasAccepted, Is.EqualTo(false));
            Assert.That(task.CurrentStatus, Is.EqualTo(Status.RefuseAccept));

            //TODO: HistoryItems
        }
Пример #8
0
        public void Doubt()
        {
            Task task = new Task
            {
                Publisher = new User(),
                Owner = new User()
            };
            task.Publish();
            task.Assign();
            task.Own();
            task.BeginWork();
            task.Doubt();

            Assert.That(task.CurrentStatus, Is.EqualTo(Status.Doubt));
        }
        public void RemoveChild()
        {
            Task parent = new Task();
            Task child_1 = new Task();
            Task child_2 = new Task();

            parent.AddChild(child_1);
            parent.AddChild(child_2);

            parent.RemoveChild(child_1);

            Assert.That(parent.Children.Count, Is.EqualTo(1));
            Assert.That(parent.Children.Contains(child_2));
            Assert.That(child_1.Parent, Is.Null);
        }
Пример #10
0
        public void Update_Property()
        {
            Task task = new Task { Publisher = new User() };
            task.Publish();

            task.UpdateProperty();
            Assert.That(task.CurrentStatus, Is.EqualTo(Status.Publish));

            task.Owner = new User();
            task.Own();
            task.BeginWork();
            task.Doubt();

            task.UpdateProperty();
            Assert.That(task.CurrentStatus, Is.EqualTo(Status.Update));
            Assert.That(task.get_latest_history().Status, Is.EqualTo(Status.Update));
        }
Пример #11
0
        public void AddChild()
        {
            Task parent = new Task();
            Task child_1 = new Task();

            parent.AddChild(child_1);
            Assert.That(child_1.Sequence, Is.EqualTo(1));
            Assert.That(parent.Children.Count, Is.EqualTo(1));
            Assert.That(parent.Children.Contains(child_1));

            Task child_2 = new Task();
            parent.AddChild(child_2);
            Assert.That(child_2.Sequence, Is.EqualTo(2));
            Assert.That(parent.Children.Count, Is.EqualTo(2));
            Assert.That(parent.Children.Contains(child_1));
            Assert.That(parent.Children.Contains(child_2));
        }
Пример #12
0
        public void ChangeParent()
        {
            Task parent_1 = new Task();
            Task parent_2 = new Task();
            Task child = new Task();

            parent_1.AddChild(child);
            Assert.That(child.Parent, Is.EqualTo(parent_1));
            Assert.That(parent_1.Children.Count, Is.EqualTo(1));
            Assert.That(parent_1.Children.Contains(child));

            child.ChangeParent(parent_2);
            Assert.That(child.Parent, Is.EqualTo(parent_2));
            Assert.That(parent_1.Children.IsNullOrEmpty(), Is.True);
            Assert.That(parent_2.Children.Count, Is.EqualTo(1));
            Assert.That(parent_2.Children.Contains(child));
        }
Пример #13
0
        public void BeginWork_With_Parent()
        {
            #region preparation

            Task task = get_task_with_parents();
            task.Owner = new User();

            Task parent = task.Parent;
            parent.IsVirtual = true;

            Task grand_parent = task.Parent.Parent;
            grand_parent.IsVirtual = true;
            User grand_parent_owner = new User();
            grand_parent.Owner = grand_parent_owner;

            #endregion

            #region the first time the task begin

            task.BeginWork();

            task.has_begin();

            parent.has_begin(Constants.CommentAutoBegin);
            Assert.That(parent.Owner, Is.EqualTo(task.Owner));
            has_auto_own(parent);

            grand_parent.has_begin(Constants.CommentAutoBegin);
            //the owner will not change because it had one before
            Assert.That(grand_parent.Owner, Is.EqualTo(grand_parent_owner));

            #endregion

            #region a second time the task's brother begin

            Task brother = new Task();
            parent.AddChild(brother);

            SystemTime.SetDateTime(now.AddMinutes(23));
            brother.BeginWork();

            Assert.That(parent.LatestUpdateTime, Is.EqualTo(now));

            #endregion
        }
Пример #14
0
        public static void FilledBy(this FullItemModel model, Task task)
        {
            model.LiteItem = new LiteItemModel();
            model.LiteItem.FilledBy(task);

            model.ActualComplete = task.ActualCompleteTime;
            model.ActualWorkPeriod = task.ActualWorkPeriod;
            model.Assign = task.AssignTime;

            //TODO: is this check necessary?
            if (task.Publisher != null)
            {
                model.Publisher = new UserModel();
                model.Publisher.FilledBy(task.Publisher);
            }
            //TODO: walkaround
            if (task.Accepter != null)
            {
                model.Accepter = new UserModel();
                model.Accepter.FilledBy(task.Accepter);
            }

            model.Created = task.CreateTime;
            model.Difficulty = task.Difficulty;

            model.ExpectedComplete = task.ExpectCompleteTime.Split();
            model.ExpectedWorkPeriod = task.ExpectWorkPeriod;
            model.LatestUpdate = task.LatestUpdateTime;
            model.OverDue = task.OverDue;
            model.Delay = task.Delay;
            model.Own = task.OwnTime;

            if (task.Owner != null)
            {
                model.Owner = new UserModel();
                model.Owner.FilledBy(task.Owner);
            }

            model.Priority = task.Priority;
            model.Quality = task.Quality;

            model.Body = task.Body;
            model.HasAccepted = task.HasAccepted;
        }
Пример #15
0
        public void Remove_And_Add_Child()
        {
            Task parent = new Task();
            Task child_1 = new Task();
            Task child_2 = new Task();

            parent.AddChild(child_1);
            parent.AddChild(child_2);

            parent.RemoveChild(child_1);
            parent.AddChild(child_1);

            Assert.That(parent.Children.Count, Is.EqualTo(2));
            Assert.That(parent.Children.Contains(child_1));
            Assert.That(parent.Children.Contains(child_2));
            Assert.That(child_1.Parent, Is.EqualTo(parent));

            Assert.That(child_1.Sequence, Is.EqualTo(3));
        }
Пример #16
0
        internal static Task CreateTask(Project project, 
            User publisher = null,
            User accepter = null, 
            User owner = null, 
            string title = "")
        {
            Task task = new Task
            {
                Title = title,
                Project = project,
                Publisher = publisher,
                Accepter = accepter,
                Owner = owner
            };
            task.Publish();

            session.Save(task);

            return task;
        }
Пример #17
0
        private void set_Tasks_With_Project()
        {
            task_root_1 = new Task { Project = root };
            task_root_2 = new Task { Project = root };
            task_root_3 = new Task { Project = root };

            task_11 = new Task { Project = project_1 };
            task_12 = new Task { Project = project_1 };
            task_13 = new Task { Project = project_1 };
            task_14 = new Task { Project = project_1 };
            task_15 = new Task { Project = project_1 };
            task_16 = new Task { Project = project_1 };

            task_21 = new Task { Project = project_2 };
            task_22 = new Task { Project = project_2 };

            task_1_11 = new Task { Project = project_1_1 };
            task_1_12 = new Task { Project = project_1_1 };
            task_1_13 = new Task { Project = project_1_1 };        
        }
Пример #18
0
        public static void FilledBy(this EditModel model, Task task)
        {
            model.TaskItem = new FullItemModel();
            model.TaskItem.FilledBy(task);


            if (task.Parent != null)
            {
                model.TaskItem.Parent = new LiteItemModel();
                model.TaskItem.Parent.FilledBy(task.Parent);
            }

            model.ExpectedComplete = task.ExpectCompleteTime.Split();
            model.TaskItem.HasAccepted = task.HasAccepted;

            if (task.GetPrevious() != null)
            {
                model.PreviousTaskId = task.GetPrevious().Id;
            }
            if (task.GetNext() != null)
            {
                model.NextTaskId = task.GetNext().Id;
            }
        }
Пример #19
0
        public void Accept_With_Parent()
        {
            #region preparation

            Task task = new Task
            {
                Project = get_project()
            };

            Task brother = new Task
            {
                Project = get_project()
            };

            Task parent = new Task
            {
                IsVirtual = true,
                Project = get_project()
            };
            parent.AddChild(task);
            parent.AddChild(brother);

            TaskQuality Quality = TaskQuality.Good;

            #endregion

            #region only the brother is accept, not affect parent

            brother.Accept(Quality);

            brother.has_accept(Quality);

            Assert.That(parent.CurrentStatus, Is.Not.EqualTo(Status.Accept));

            #endregion

            #region both the brother and task are accepted, affect their parent now

            task.Accept(Quality);
            task.AutoAcceptAncestors();

            task.has_accept(Quality);

            parent.has_accept(Constants.CommentAutoAcceptForChildren);
            Assert.That(parent.Quality, Is.Null);

            #endregion
        }
Пример #20
0
        public void Accept_When_Owner_Is_Accepter()
        {
            User user = new User();
            Task task = new Task
            {
                Owner = user,
                Accepter = user
            };
            task.BeginWork();
            task.Complete();

            task.has_accept(Constants.CommentAutoAcceptForOwnerIsAccepter);
        }
Пример #21
0
 private void setParent(Task task, LiteItemModel parent)
 {
     if (parent.Id.HasValue)
     {
         Task newParent = session.Load<Task>(parent.Id);
         task.ChangeParent(newParent);
     }
     else
     {
         task.RemoveParent();
     }
 }
Пример #22
0
 private void addParent(Task task, LiteItemModel parent)
 {
     if (parent.Id.HasValue)
     {
         Task parentTask = session.Load<Task>(parent.Id);
         parentTask.AddChild(task);
     }
 }
Пример #23
0
        private void has_auto_own(Task parent)
        {
            HistoryItem own_history = parent.Histroy[0];

            Assert.That(own_history.Status, Is.EqualTo(Status.Own));
            Assert.That(own_history.Description, Is.EqualTo(Constants.CommentAutoOwn));
        }
Пример #24
0
        private void addDoubt(IList<StatusModel> qualified, Task task)
        {
            StatusModel doubtModel = new StatusModel();
            doubtModel.FilledBy(Status.Doubt);

            if (task.Publisher != task.Owner || task.Owner != task.Accepter)
            {
                qualified.Add(doubtModel);
            }
        }
Пример #25
0
        public int Create(NewModel model, int creatorId)
        {
            Task task = new Task();

            task.Publisher = session.Load<User>(creatorId);
            task.Project = session.Load<Project>(model.CurrentProject.TailSelectedProject.Id);
            addParent(task, model.TaskItem.Parent);
            setAccepter(task, model.TaskItem.Accepter);

            model.TaskItem.Fill(task);

            task.Publish();

            session.Save(task);
            session.Flush();
            // important: to ensure the task is published first and then assigned later!

            if (model.TaskItem.Owner.Id.HasValue)
            {
                task.Owner = session.Load<User>(model.TaskItem.Owner.Id.Value);
                task.Assign();
            }

            return task.Id;
        }
Пример #26
0
        private Task get_task_with_brothers_and_parents()
        {
            Task root = new Task { Accepter = new User() };
            root.BeginWork();

            Task branch_1 = new Task { Accepter = new User() };
            branch_1.BeginWork();
            root.AddChild(branch_1);

            Task branch_2 = new Task { Accepter = new User() };
            branch_2.CurrentStatus = Status.Complete;
            root.AddChild(branch_2);

            Task leaf_1 = new Task { Accepter = new User() };
            leaf_1.BeginWork();
            branch_1.AddChild(leaf_1);

            Task leaf_2 = new Task { Accepter = new User() };
            leaf_2.CurrentStatus = Status.Complete;
            branch_1.AddChild(leaf_2);

            return leaf_1;
        }
Пример #27
0
 private Task get_task_with_parents()
 {
     Task task = new Task();
     task.AddChild(new Task());
     task.Children[0].AddChild(new Task());
     return task.Children[0].Children[0];
 }
Пример #28
0
        private IList<StatusModel> getQualifiedStatus(Status status, Task task)
        {
            IList<StatusModel> qualified = new List<StatusModel>();

            StatusModel beginWorkModel = new StatusModel();
            beginWorkModel.FilledBy(Status.BeginWork);

            StatusModel quitModel = new StatusModel();
            quitModel.FilledBy(Status.Quit);

            StatusModel completeModel = new StatusModel();
            completeModel.FilledBy(Status.Complete);

            StatusModel pauseModel = new StatusModel();
            pauseModel.FilledBy(Status.Pause);

            StatusModel dissentModel = new StatusModel();
            dissentModel.FilledBy(Status.Dissent);

            if (status == Status.Assign
                || status == Status.Own
                || status == Status.Dissent)
            {
                qualified.Add(beginWorkModel);
                qualified.Add(quitModel);
            }
            else if (status == Status.BeginWork)
            {
                qualified.Add(completeModel);
                qualified.Add(pauseModel);
                qualified.Add(quitModel);
                addDoubt(qualified, task);
            }
            else if (status == Status.Pause)
            {
                qualified.Add(beginWorkModel);
                qualified.Add(quitModel);
                addDoubt(qualified, task);
                qualified.Add(completeModel);
            }
            else if (status == Status.Doubt
                || status == Status.Update)
            {
                qualified.Add(beginWorkModel);
                qualified.Add(quitModel);
                qualified.Add(completeModel);
            }
            else if (status == Status.Complete)
            {
                qualified.Add(beginWorkModel);
            }
            else if (status == Status.RefuseAccept)
            {
                qualified.Add(beginWorkModel);
                qualified.Add(quitModel);
                qualified.Add(dissentModel);
            }
            return qualified;
        }
Пример #29
0
 private static void set_task_status(Task task, Status status)
 {
     switch (status)
     {
         case Status.Assign:
             task.Assign();
             break;
         case Status.Remove:
             task.Remove();
             break;
         case Status.BeginWork:
             task.Assign();
             task.BeginWork();
             break;
         case Status.Complete:
             task.Assign();
             task.BeginWork();
             task.Complete();
             break;
         case Status.Accept:
             task.Assign();
             task.BeginWork();
             task.Complete();
             task.Accept(null);
             break;
     }
 }
Пример #30
0
 private void setAccepter(Task task, UserModel accepter)
 {
     if (accepter.Id.HasValue)
     {
         task.Accepter = session.Load<User>(accepter.Id.Value);
     }
     else
     {
         task.Accepter = task.Publisher;
     }
 }