Exemple #1
0
        private bool IsCreator(Teams.Team team, Teams.Task task, Account a)
        {
            var m = team.GetMember(task.CreatorMemberId);

            //TODO:由于Member可能被删除,teamtask可能找不到创建者?
            if (m == null || !m.AssociatedAccountId.HasValue)
            {
                return(false);
            }
            var account = _accountService.GetAccount(m.AssociatedAccountId.Value);

            return(account != null && account.ID == a.ID);
        }
Exemple #2
0
        public void AddTag()
        {
            var account = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var task = new Task(creatorMember, team);
            task.AddTag("程序设计");
            task.AddTag(".NET");
            task.AddTag(".net");
            task.AddTag("∮   ∮;∮;");
            task.AddTag("∮bb∮");
            task.AddTag("∮∮ ∮b∮a∮");
            task.AddTag("A ");
            task.AddTag("∮∮ ∮)∮)∮)");
            task.AddTag("∮∮ ∮)∮)∮)");
            task.AddTag("001_Tag_001");
            this._teamTaskService.Create(task);

            this.Evict(task);

            task = this._teamTaskService.GetTask(task.ID);
            Assert.AreEqual(8, task.Tags.Count());

            Assert.IsFalse(task.Tags.Any(x => x == ".NET"));
            Assert.IsFalse(task.Tags.Any(x => x == "a"));
            Assert.IsFalse(task.Tags.Any(x => x == "A "));
            Assert.IsFalse(task.Tags.Any(x => x == ";"));
            Assert.IsFalse(task.Tags.Any(x => x == ")"));

            Assert.IsTrue(task.Tags.Any(x => x == "程序设计"));
            Assert.IsTrue(task.Tags.Any(x => x == ".net"));
            Assert.IsTrue(task.Tags.Any(x => x == ";"));
            Assert.IsTrue(task.Tags.Any(x => x == "bb"));
            Assert.IsTrue(task.Tags.Any(x => x == "A"));
            Assert.IsTrue(task.Tags.Any(x => x == "b"));
            Assert.IsTrue(task.Tags.Any(x => x == ")"));
            Assert.IsTrue(task.Tags.Any(x => x == "001_Tag_001"));
        }
Exemple #3
0
        public void AddRemoveCommentTest()
        {
            var account = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var task = new Task(creatorMember, team);
            var memberName = RandomString();
            var memberEmail = RandomEmailString();
            var member = this._teamService.AddFullMember(memberName, memberEmail, team);

            var comment1 = RandomString();
            var comment2 = RandomString();
            task.AddComment(member, comment1);
            task.AddComment(member, comment2);

            this._teamTaskService.Create(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);

            Assert.AreEqual(2, task.Comments.Count());
            Assert.IsTrue(task.Comments.Any(x => x.Body == comment1));
            Assert.IsTrue(task.Comments.Any(x => x.Body == comment2));

            task.RemoveComment(task.Comments.Single(x => x.Body == comment1));
            this._teamTaskService.Update(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.AreEqual(1, task.Comments.Count());
            Assert.IsTrue(task.Comments.Any(x => x.Body == comment2));

            task.RemoveComment(task.Comments.First());
            this._teamTaskService.Update(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.AreEqual(0, task.Comments.Count());
        }
Exemple #4
0
        public ActionResult Sync(string teamId
                                 , string projectId
                                 , string memberId
                                 , string tag
                                 , string taskKey
                                 , string taskId
                                 , string changes
                                 , string by
                                 , string sorts)
        {
            var a             = this.Context.Current;
            var team          = this.GetTeamOfCurrentAccount(teamId);
            var project       = string.IsNullOrWhiteSpace(projectId) ? null : this.GetProject(team, projectId);
            var member        = string.IsNullOrWhiteSpace(memberId) ? null : this.GetMember(team, memberId);
            var currentMember = this.GetCurrentMember(team);

            tag = (tag ?? string.Empty).Trim();

            return(Json(this.Sync(changes, by, sorts
                                  , o => this.ApplyOtherChanges(team, o)
                                  , () =>
            {
                var t = new Teams.Task(currentMember, team);

                #region 默认值设置
                if (project != null)
                {
                    t.AddToProject(project);
                    if (this._log.IsInfoEnabled)
                    {
                        this._log.InfoFormat("默认为新任务设置项目#{0}|{1}", project.ID, project.Name);
                    }
                }
                if (member != null)
                {
                    t.AssignTo(member);
                    if (this._log.IsInfoEnabled)
                    {
                        this._log.InfoFormat("默认将新任务分配给#{0}|{1}", member.ID, member.Name);
                    }
                }
                if (!string.IsNullOrWhiteSpace(tag))
                {
                    t.AddTag(tag);
                    if (this._log.IsInfoEnabled)
                    {
                        this._log.InfoFormat("默认为新任务设置标签#{0}", tag);
                    }
                }
                #endregion

                return t;
            }
                                  , (o, c) =>
            {
                var task = o as Teams.Task;

                //团队成员可发表评论
                if (!string.IsNullOrWhiteSpace(c.Name) && //delete变更没有name
                    c.Name.Equals("comments", StringComparison.InvariantCultureIgnoreCase))
                {
                    Assert.IsTrue(this.IsTeamOfCurrentAccount(team));
                }
                else
                {
                    //任务创建者或执行人
                    Assert.IsTrue(this.IsCreator(team, task, a) || this.IsAssignee(task, currentMember));
                }
            }
                                  //是否是属于个人的排序
                                  , () => project == null &&
                                  string.IsNullOrWhiteSpace(memberId) &&
                                  string.IsNullOrWhiteSpace(tag) &&
                                  string.IsNullOrWhiteSpace(taskKey) &&
                                  string.IsNullOrWhiteSpace(taskId)
                                  //个人排序key
                                  , o => this.GetSortKey(team, o)
                                  , o =>
            {
                #region 保存非个人排序数据
                //HACK:若有memberId则认为是查看member视图,此时不对排序数据做保存
                if (project != null)
                {
                    //存储至项目排序数据
                    project.Settings[by] = o;
                    this._teamService.Update(team);
                    if (this._log.IsDebugEnabled)
                    {
                        this._log.DebugFormat("将{0}排序数据保存至项目#{1}:{2}", by, project.ID, o);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(tag))
                {
                    team.Settings[this.GetSortKey(by, tag)] = o;
                    this._teamService.Update(team);
                    if (this._log.IsDebugEnabled)
                    {
                        this._log.DebugFormat("将{0}|{1}排序数据保存至团队#{2}:{3}", by, tag, team.ID, o);
                    }
                }
                #endregion
            })));
        }
Exemple #5
0
 void ITaskService.Update(Task task)
 {
     _repository.Update(task);
 }
Exemple #6
0
 void ITaskService.Delete(Task task)
 {
     _repository.Remove(task);
     if (this._log.IsInfoEnabled)
         this._log.InfoFormat("删除团队任务#{0}", task.ID);
 }
Exemple #7
0
 void ITaskService.Create(Task task)
 {
     _repository.Add(task);
     if (this._log.IsInfoEnabled)
         this._log.InfoFormat("新增团队任务#{0}|{1}|{2}", task.ID, task.Subject, task.CreatorMemberId);
 }
Exemple #8
0
        public void DeleteTeamTask()
        {
            var a = this.CreateAccount();
            var team = CreateSampleTeam();
            var member = AddSampleMemberToTeam(team);
            var project = AddSampleProjectToTeam(team);
            var task = new Task(member, team);
            task.AssignTo(member);
            task.AddToProject(project);
            this._teamTaskService.Create(task);

            this.Evict(task);

            var task2 = this._teamTaskService.GetTask(task.ID);

            _teamTaskService.Delete(task2);

            this.Evict(task2);

            var task3 = this._teamTaskService.GetTask(task2.ID);

            Assert.IsNull(task3);
        }
Exemple #9
0
        public void ClearTaskProjectsAfterTeamMemberRemovedTest()
        {
            var account = CreateAccount();
            var team = CreateSampleTeam();
            var member = AddSampleMemberToTeam(team);
            var project = AddSampleProjectToTeam(team);
            var task = new Task(member, team);
            task.AddToProject(project);
            this._teamTaskService.Create(task);
            this.Evict(member);
            this.Evict(team);
            this.Evict(task);
            this.Evict(project);
            team = _teamService.GetTeam(team.ID);
            member = team.GetMember(member.ID);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNotNull(task);
            Assert.AreEqual(1, task.ProjectIds.Count());

            this._teamService.RemoveProject(project, team);
            this.Evict(project);
            this.Evict(team);
            this.Evict(task);
            team = this._teamService.GetTeam(team.ID);
            project = team.GetProject(project.ID);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNull(project);
            Assert.IsNotNull(task);
            Assert.AreEqual(0, task.ProjectIds.Count());
        }
Exemple #10
0
        public void ClearCommentCreatorsAfterTeamMemberRemovedTest()
        {
            var account = CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var member = AddSampleMemberToTeam(team);
            var task = new Task(creatorMember, team);
            var comment = RandomString();
            task.AddComment(member, comment);
            this._teamTaskService.Create(task);

            this.Evict(member);
            this.Evict(team);
            this.Evict(task);
            this.Evict(comment);

            team = _teamService.GetTeam(team.ID);
            member = team.GetMember(member.ID);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNotNull(task);
            Assert.AreEqual(1, task.Comments.Count());
            Assert.IsTrue(task.Comments.Any(x => x.Body == comment && x.Creator.ID == member.ID));

            this._teamService.RemoveMember(member, team);

            this.Evict(task);
            this.Evict(comment);

            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNotNull(task);
            Assert.AreEqual(1, task.Comments.Count());
            Assert.IsTrue(task.Comments.Any(x => x.Body == comment && x.Creator == null));
        }
Exemple #11
0
        public void TrashTaskTest()
        {
            var account = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var task = new Task(creatorMember, team);

            this._teamTaskService.Create(task);

            var taskId = task.ID;

            this.Evict(task);

            task = this._teamTaskService.GetTask(task.ID);

            task.MarkAsTrashed();
            this._teamTaskService.Update(task);

            this.Evict(task);

            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNull(task);

            var tasks = this._teamTaskService.GetTasksByAccount(team, account);
            Assert.AreEqual(0, tasks.Count());

            tasks = this._teamTaskService.GetTrashedTasks(team);
            Assert.AreEqual(1, tasks.Count());
            Assert.AreEqual(taskId, tasks.First().ID);

            task = tasks.First();
            task.MarkAsUnTrashed();
            this._teamTaskService.Update(task);

            this.Evict(task);

            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNotNull(task);

            tasks = this._teamTaskService.GetTrashedTasks(team);
            Assert.AreEqual(0, tasks.Count());
        }
Exemple #12
0
        public void RemoveTaskFromProjectTest()
        {
            var account = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var project1 = AddSampleProjectToTeam(team);
            var project2 = AddSampleProjectToTeam(team);
            var task = new Task(creatorMember, team);
            task.AddToProject(project1);
            task.AddToProject(project2);
            this._teamTaskService.Create(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.AreEqual(2, task.ProjectIds.Count());
            Assert.IsTrue(task.ProjectIds.Any(x => x.ID == project1.ID));
            Assert.IsTrue(task.ProjectIds.Any(x => x.ID == project2.ID));

            task.RemoveFromProject(project1);
            this._teamTaskService.Update(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.AreEqual(1, task.ProjectIds.Count());
            Assert.IsTrue(task.ProjectIds.Any(x => x.ID == project2.ID));

            task.RemoveFromProject(project2);
            this._teamTaskService.Update(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.AreEqual(0, task.ProjectIds.Count());
        }
Exemple #13
0
        public void RemoveTaskAssigneeTest()
        {
            var account = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var member1 = AddSampleMemberToTeam(team);
            var member2 = AddSampleMemberToTeam(team);
            var task = new Task(creatorMember, team);
            task.AssignTo(member1);
            this._teamTaskService.Create(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNotNull(task.AssigneeId);
            Assert.AreEqual(member1.ID, task.AssigneeId.Value);

            task.AssignTo(member2);
            this._teamTaskService.Update(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNotNull(task.AssigneeId);
            Assert.AreEqual(member2.ID, task.AssigneeId.Value);

            task.RemoveAssignee();
            this._teamTaskService.Update(task);
            this.Evict(task);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNull(task.AssigneeId);
        }
Exemple #14
0
        public void GetTasksTest()
        {
            var account1 = this.CreateAccount();
            var account2 = this.CreateAccount();
            var team = CreateSampleTeam();
            var member1 = AddSampleMemberToTeam(account1, team);
            var member2 = AddSampleMemberToTeam(account2, team);
            var project1 = AddSampleProjectToTeam(team);
            var project2 = AddSampleProjectToTeam(team);

            var teamTask1 = new Task(member1, team);
            teamTask1.AssignTo(member2);
            teamTask1.MarkAsCompleted();
            teamTask1.AddToProject(project1);

            var teamTask2 = new Task(member2, team);
            teamTask2.AssignTo(member1);
            teamTask2.MarkAsCompleted();
            teamTask2.AddToProject(project2);

            var teamTask3 = new Task(member1, team);
            teamTask3.AssignTo(member1);
            teamTask3.AddToProject(project1);

            this._teamTaskService.Create(teamTask1);
            this._teamTaskService.Create(teamTask2);
            this._teamTaskService.Create(teamTask3);

            var member1Tasks = this._teamTaskService.GetTasksByMember(member1);
            Assert.AreEqual(2, member1Tasks.Count());
            Assert.IsTrue(member1Tasks.Any(x => x.ID == teamTask2.ID));
            Assert.IsTrue(member1Tasks.Any(x => x.ID == teamTask3.ID));

            var member2Tasks = this._teamTaskService.GetTasksByMember(member2);
            Assert.AreEqual(1, member2Tasks.Count());
            Assert.IsTrue(member2Tasks.Any(x => x.ID == teamTask1.ID));

            var incompletedMember1Tasks = this._teamTaskService.GetIncompletedTasksByMember(member1);
            Assert.AreEqual(1, incompletedMember1Tasks.Count());
            Assert.IsTrue(incompletedMember1Tasks.Any(x => x.ID == teamTask3.ID));

            var incompletedMember2Tasks = this._teamTaskService.GetIncompletedTasksByMember(member2);
            Assert.AreEqual(0, incompletedMember2Tasks.Count());

            var teamTasks1OfCreatorOrAssignee = this._teamTaskService.GetTasksByAccount(team, account1);
            Assert.AreEqual(3, teamTasks1OfCreatorOrAssignee.Count());
            Assert.IsTrue(teamTasks1OfCreatorOrAssignee.Any(x => x.ID == teamTask1.ID));
            Assert.IsTrue(teamTasks1OfCreatorOrAssignee.Any(x => x.ID == teamTask2.ID));
            Assert.IsTrue(teamTasks1OfCreatorOrAssignee.Any(x => x.ID == teamTask3.ID));

            var teamTasks2OfCreatorOrAssignee = this._teamTaskService.GetTasksByAccount(team, account2);
            Assert.AreEqual(2, teamTasks2OfCreatorOrAssignee.Count());
            Assert.IsTrue(teamTasks2OfCreatorOrAssignee.Any(x => x.ID == teamTask1.ID));
            Assert.IsTrue(teamTasks2OfCreatorOrAssignee.Any(x => x.ID == teamTask2.ID));

            var incompletedTeamTasks1OfCreatorOrAssignee = this._teamTaskService.GetIncompletedTasksByAccount(team, account1);
            Assert.AreEqual(1, incompletedTeamTasks1OfCreatorOrAssignee.Count());
            Assert.IsTrue(incompletedTeamTasks1OfCreatorOrAssignee.Any(x => x.ID == teamTask3.ID));

            var incompletedTeamTasks2OfCreatorOrAssignee = this._teamTaskService.GetIncompletedTasksByAccount(team, account2);
            Assert.AreEqual(0, incompletedTeamTasks2OfCreatorOrAssignee.Count());

            var project1Tasks = this._teamTaskService.GetTasksByProject(project1);
            Assert.AreEqual(2, project1Tasks.Count());
            Assert.IsTrue(project1Tasks.Any(x => x.ID == teamTask1.ID));
            Assert.IsTrue(project1Tasks.Any(x => x.ID == teamTask3.ID));

            var project2Tasks = this._teamTaskService.GetTasksByProject(project2);
            Assert.AreEqual(1, project2Tasks.Count());
            Assert.IsTrue(project2Tasks.Any(x => x.ID == teamTask2.ID));

            var project1IncompletedTasks = this._teamTaskService.GetIncompletedTasksByProject(project1);
            Assert.AreEqual(1, project1IncompletedTasks.Count());
            Assert.IsTrue(project1IncompletedTasks.Any(x => x.ID == teamTask3.ID));

            var project2IncompletedTasks = this._teamTaskService.GetIncompletedTasksByProject(project2);
            Assert.AreEqual(0, project2IncompletedTasks.Count());
        }
Exemple #15
0
        public void GetTasksByKeyTest()
        {
            var account = CreateAccount();
            var team = CreateSampleTeam();
            var member = AddSampleMemberToTeam(account, team);

            var teamTask1 = new Task(member, team);
            teamTask1.SetSubject(".NET 4.5 researching");
            teamTask1.SetBody("Research what is new in .NET 4.5, and is there any problems to upgrade to .NET4.5");
            teamTask1.MarkAsInCompleted();

            var teamTask2 = new Task(member, team);
            teamTask2.SetSubject("Compare .NET and Java platform.");
            teamTask2.SetBody("Compare the most important differences between .NET and java platform.");
            teamTask2.MarkAsInCompleted();

            var teamTask3 = new Task(member, team);
            teamTask3.SetSubject("A sample task to test GetTasksByKey interface.");
            teamTask3.AddComment(member, ".net");
            teamTask3.AddComment(member, ".net");
            teamTask3.AddComment(member, "java");
            teamTask3.AddComment(member, "other");
            teamTask3.MarkAsCompleted();

            this._teamTaskService.Create(teamTask1);
            this._teamTaskService.Create(teamTask2);
            this._teamTaskService.Create(teamTask3);

            var tasks = this._teamTaskService.GetTasksByKey(team, ".NET");
            var incompletedTasks = this._teamTaskService.GetIncompletedTasksByKey(team, ".NET");
            Assert.AreEqual(3, tasks.Count());
            Assert.IsTrue(tasks.Any(x => x.ID == teamTask1.ID));
            Assert.IsTrue(tasks.Any(x => x.ID == teamTask2.ID));
            Assert.IsTrue(tasks.Any(x => x.ID == teamTask3.ID));
            Assert.AreEqual(2, incompletedTasks.Count());
            Assert.IsTrue(incompletedTasks.Any(x => x.ID == teamTask1.ID));
            Assert.IsTrue(incompletedTasks.Any(x => x.ID == teamTask2.ID));

            tasks = this._teamTaskService.GetTasksByKey(team, "JAVA");
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByKey(team, "JAVA");
            Assert.AreEqual(2, tasks.Count());
            Assert.IsTrue(tasks.Any(x => x.ID == teamTask2.ID));
            Assert.IsTrue(tasks.Any(x => x.ID == teamTask3.ID));
            Assert.AreEqual(1, incompletedTasks.Count());
            Assert.IsTrue(incompletedTasks.Any(x => x.ID == teamTask2.ID));

            tasks = this._teamTaskService.GetTasksByKey(team, "OTHER");
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByKey(team, "OTHER");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsTrue(tasks.Any(x => x.ID == teamTask3.ID));
            Assert.AreEqual(0, incompletedTasks.Count());

            tasks = this._teamTaskService.GetTasksByKey(team, "Not Exist Key");
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByKey(team, "Not Exist Key");
            Assert.AreEqual(0, tasks.Count());
            Assert.AreEqual(0, incompletedTasks.Count());

            tasks = this._teamTaskService.GetTasksByKey(team, null);
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByKey(team, null);
            Assert.AreEqual(0, tasks.Count());
            Assert.AreEqual(0, incompletedTasks.Count());

            tasks = this._teamTaskService.GetTasksByKey(team, string.Empty);
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByKey(team, string.Empty);
            Assert.AreEqual(0, tasks.Count());
            Assert.AreEqual(0, incompletedTasks.Count());

            tasks = this._teamTaskService.GetTasksByKey(team, " ");
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByKey(team, " ");
            Assert.AreEqual(0, tasks.Count());
            Assert.AreEqual(0, incompletedTasks.Count());
        }
Exemple #16
0
        public void GetTags()
        {
            var account = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var task1 = new Task(creatorMember, team);
            task1.AddTag("程序设计");
            task1.AddTag(".NET");
            task1.AddTag("ASP.NET");
            task1.AddTag("001_Tag_001");
            task1.MarkAsCompleted();
            this._teamTaskService.Create(task1);
            var task2 = new Task(creatorMember, team);
            task2.AddTag("Mono");
            task2.AddTag(".net");
            task2.AddTag("JAVA");
            task2.AddTag("JAVA.NET");
            task2.AddTag("001_tag_001");
            this._teamTaskService.Create(task2);

            this.Evict(task1);
            this.Evict(task2);

            var tasks = this._teamTaskService.GetTasksByTag(team, ".net");
            Assert.AreEqual(2, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains(".net", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "java");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("java", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "程序设计");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("程序设计", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "Mono");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("Mono", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "001_tag_001");
            Assert.AreEqual(2, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("001_tag_001", StringComparer.OrdinalIgnoreCase)));

            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, ".net");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains(".net", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "java");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("java", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "程序设计");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("程序设计", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "Mono");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("Mono", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "001_tag_001");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("001_tag_001", StringComparer.OrdinalIgnoreCase)));

            task1 = this._teamTaskService.GetTask(task1.ID);
            task2 = this._teamTaskService.GetTask(task2.ID);

            task1.RemoveTag(".net");
            task2.RemoveTag("001_tag_001");
            task2.RemoveTag("JAVA");

            this._teamTaskService.Update(task1);
            this._teamTaskService.Update(task2);

            this.Evict(task1);
            this.Evict(task2);

            tasks = this._teamTaskService.GetTasksByTag(team, ".net");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains(".net", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "java");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("java", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "程序设计");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("程序设计", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "Mono");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("Mono", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetTasksByTag(team, "001_tag_001");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("001_tag_001", StringComparer.OrdinalIgnoreCase)));

            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, ".net");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains(".net", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "java");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("java", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "程序设计");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("程序设计", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "Mono");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("Mono", StringComparer.OrdinalIgnoreCase)));
            tasks = this._teamTaskService.GetIncompletedTasksByTag(team, "001_tag_001");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("001_tag_001", StringComparer.OrdinalIgnoreCase)));

            tasks = this._teamTaskService.GetTasksByTag(team, null);
            var incompletedTasks = this._teamTaskService.GetIncompletedTasksByTag(team, null);
            Assert.AreEqual(0, tasks.Count());
            Assert.AreEqual(0, incompletedTasks.Count());

            tasks = this._teamTaskService.GetTasksByTag(team, string.Empty);
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByTag(team, string.Empty);
            Assert.AreEqual(0, tasks.Count());
            Assert.AreEqual(0, incompletedTasks.Count());

            tasks = this._teamTaskService.GetTasksByTag(team, " ");
            incompletedTasks = this._teamTaskService.GetIncompletedTasksByTag(team, " ");
            Assert.AreEqual(0, tasks.Count());
            Assert.AreEqual(0, incompletedTasks.Count());
        }
Exemple #17
0
 private bool IsAssignee(Teams.Task task, Teams.Member member)
 {
     return(task.AssigneeId.HasValue && task.AssigneeId == member.ID);
 }
Exemple #18
0
        public void UpdateTeamTask()
        {
            var a = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(a, team);
            var member = AddSampleMemberToTeam(team);
            var project = AddSampleProjectToTeam(team);
            var task = new Task(creatorMember, team);
            task.AssignTo(member);
            task.AddToProject(project);
            this._teamTaskService.Create(task);

            this.Evict(task);

            var task2 = this._teamTaskService.GetTask(task.ID);
            var member2 = AddSampleMemberToTeam(team);

            task2.AssignTo(member2);
            task2.RemoveFromProject(project);

            Assert.AreEqual(member2.ID, task2.AssigneeId.Value);
            Assert.AreEqual(0, task2.ProjectIds.Count());

            this._teamTaskService.Update(task2);
            this.Evict(task2);
            var task3 = this._teamTaskService.GetTask(task2.ID);

            Assert.AreEqual(task2.Subject, task3.Subject);
            Assert.AreEqual(task2.Body, task3.Body);
            Assert.AreEqual(task2.Priority, task3.Priority);
            Assert.AreEqual(task2.DueTime, task3.DueTime);
            Assert.AreEqual(task2.IsCompleted, task3.IsCompleted);
            Assert.AreEqual(task2.CreatorMemberId, task3.CreatorMemberId);

            Assert.AreEqual(task2.TeamId, task3.TeamId);
            Assert.AreEqual(task2.AssigneeId.Value, task3.AssigneeId.Value);
            Assert.AreEqual(task2.ProjectIds.Count(), task3.ProjectIds.Count());

            this.Evict(task3);

            var task4 = this._teamTaskService.GetTask(task3.ID);

            task4.RemoveAssignee();

            Assert.AreEqual(null, task4.AssigneeId);

            this._teamTaskService.Update(task4);
            this.Evict(task4);
            var task5 = this._teamTaskService.GetTask(task4.ID);

            Assert.AreEqual(task4.AssigneeId, task5.AssigneeId);
        }
Exemple #19
0
        public void ClearTaskAssigneeAfterTeamMemberRemovedTest()
        {
            var account = CreateAccount();
            var team = CreateSampleTeam();
            var member = AddSampleMemberToTeam(team);
            var task = new Task(member, team);
            task.AssignTo(member);
            this._teamTaskService.Create(task);
            this.Evict(member);
            this.Evict(team);
            this.Evict(task);
            team = _teamService.GetTeam(team.ID);
            member = team.GetMember(member.ID);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNotNull(task);
            Assert.IsNotNull(task.AssigneeId);
            Assert.AreEqual(member.ID, task.AssigneeId.Value);

            this._teamService.RemoveMember(member, team);
            this.Evict(member);
            this.Evict(team);
            this.Evict(task);
            team = _teamService.GetTeam(team.ID);
            member = team.GetMember(member.ID);
            task = this._teamTaskService.GetTask(task.ID);
            Assert.IsNull(member);
            Assert.IsNotNull(task);
            Assert.IsNull(task.AssigneeId);
        }
Exemple #20
0
 /// <summary>断言团队任务是否有效
 /// </summary>
 /// <param name="task"></param>
 public static void IsValid(Cooper.Model.Teams.Task task)
 {
     Assert.IsValid(task as Cooper.Model.Tasks.Task);
     Assert.Greater(task.TeamId, 0);
 }
Exemple #21
0
        public void GetTags()
        {
            var account = this.CreateAccount();
            var team = CreateSampleTeam();
            var creatorMember = AddSampleMemberToTeam(account, team);
            var task1 = new Task(creatorMember, team);
            task1.AddTag("程序设计");
            task1.AddTag(".NET");
            task1.AddTag("ASP.NET");
            task1.AddTag("001_Tag_001");
            task1.MarkAsCompleted();
            this._teamTaskService.Create(task1);
            var task2 = new Task(creatorMember, team);
            task2.AddTag("Mono");
            task2.AddTag(".net");
            task2.AddTag("JAVA");
            task2.AddTag("JAVA.NET");
            task2.AddTag("001_tag_001");
            this._teamTaskService.Create(task2);

            this.Evict(task1);
            this.Evict(task2);

            var tags = this._teamService.GetTagsByTeam(team);
            Assert.AreEqual(7, tags.Count());
            Assert.IsTrue(tags.Any(x => x == "程序设计"));
            Assert.IsTrue(tags.Any(x => x == ".NET"));
            Assert.IsTrue(tags.Any(x => x == "ASP.NET"));
            Assert.IsTrue(tags.Any(x => x == "001_Tag_001"));
            Assert.IsTrue(tags.Any(x => x == "Mono"));
            Assert.IsTrue(tags.Any(x => x == "JAVA"));
            Assert.IsTrue(tags.Any(x => x == "JAVA.NET"));
        }
Exemple #22
0
        public void CreateTeamTask()
        {
            var a = this.CreateAccount();
            var team = CreateSampleTeam();
            var member = AddSampleMemberToTeam(team);
            var project = AddSampleProjectToTeam(team);
            var task = new Task(member, team);
            task.AssignTo(member);
            task.AddToProject(project);

            Assert.AreNotEqual(DateTime.MinValue, task.CreateTime);
            Assert.AreNotEqual(DateTime.MinValue, task.LastUpdateTime);

            Assert.AreEqual(member.ID, task.CreatorMemberId);
            Assert.AreEqual(project.ID, task.ProjectIds.First().ID);
            Assert.AreEqual(team.ID, task.TeamId);
            Assert.AreEqual(1, task.ProjectIds.Count());
            Assert.AreEqual(project.ID, task.ProjectIds.First().ID);

            this._teamTaskService.Create(task);
            Assert.Greater(task.ID, 0);

            this.Evict(task);

            var task2 = this._teamTaskService.GetTask(task.ID);

            Assert.AreEqual(task.Subject, task2.Subject);
            Assert.AreEqual(task.Body, task2.Body);
            Assert.AreEqual(task.Priority, task2.Priority);
            Assert.AreEqual(task.DueTime, task2.DueTime);
            Assert.AreEqual(task.IsCompleted, task2.IsCompleted);
            Assert.AreEqual(task.CreatorMemberId, task2.CreatorMemberId);

            Assert.AreEqual(task.TeamId, task2.TeamId);
            Assert.AreEqual(task.AssigneeId.Value, task2.AssigneeId.Value);
            Assert.AreEqual(task.ProjectIds.Count(), task2.ProjectIds.Count());
            Assert.AreEqual(task.ProjectIds.First().ID, task2.ProjectIds.First().ID);
        }