예제 #1
0
        public void Create()
        {
            var a = this.CreateAccount();
            var task = new PersonalTask(a);
            Assert.AreNotEqual(DateTime.MinValue, task.CreateTime);
            Assert.AreNotEqual(DateTime.MinValue, task.LastUpdateTime);

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

            this.Evict(task);

            var task2 = this._personalTaskService.GetTask(task.ID);
            this.Dump(task2);
            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.CreateTime, task2.CreateTime);
            //Assert.AreEqual(task.LastUpdateTime, task2.LastUpdateTime);
            Assert.AreEqual(task.CreatorAccountId, task2.CreatorAccountId);
            Assert.AreEqual(task.TaskFolderId, task2.TaskFolderId);
        }
예제 #2
0
        public void DeletePersonalTask()
        {
            var account = this.CreateAccount();
            var task = new PersonalTask(account);
            this._taskService.Create(task);

            this.Evict(task);

            var task2 = this._taskService.GetTask(task.ID) as PersonalTask;

            _taskService.Delete(task2);

            this.Evict(task2);

            var task3 = this._taskService.GetTask(task2.ID) as PersonalTask;

            Assert.IsNull(task3);
        }
예제 #3
0
        public void CreatePersonalTask()
        {
            var account = this.CreateAccount();
            var task = new PersonalTask(account);
            Assert.AreNotEqual(DateTime.MinValue, task.CreateTime);
            Assert.AreNotEqual(DateTime.MinValue, task.LastUpdateTime);

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

            this.Evict(task);

            var task2 = this._taskService.GetTask(task.ID) as PersonalTask;
            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(FormatTime(task.CreateTime), FormatTime(task2.CreateTime));
            Assert.AreEqual(FormatTime(task.LastUpdateTime), FormatTime(task2.LastUpdateTime));
            Assert.AreEqual(task.CreatorAccountId, task2.CreatorAccountId);
        }
예제 #4
0
        public void AddTag()
        {
            var account = this.CreateAccount();
            var task = new PersonalTask(account);
            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._personalTaskService.Create(task);

            this.Evict(task);

            task = this._personalTaskService.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"));
        }
예제 #5
0
 public void LastUpdateTime()
 {
     var a = this.CreateAccount();
     var task = new PersonalTask(a);
     //subjet
     var old = task.LastUpdateTime;
     this.Idle();
     task.SetSubject(task.Subject);
     Assert.AreEqual(task.LastUpdateTime, old);
     task.SetSubject(string.Empty);
     Assert.Greater(task.LastUpdateTime, old);
     //body
     old = task.LastUpdateTime;
     this.Idle();
     task.SetBody(task.Body);
     Assert.AreEqual(task.LastUpdateTime, old);
     task.SetBody(string.Empty);
     Assert.Greater(task.LastUpdateTime, old);
     //dueTime
     old = task.LastUpdateTime;
     this.Idle();
     task.SetDueTime(null);
     Assert.Greater(task.LastUpdateTime, old);
     //priority
     old = task.LastUpdateTime;
     this.Idle();
     task.SetPriority(task.Priority);
     Assert.AreEqual(task.LastUpdateTime, old);
     task.SetPriority(Priority.Upcoming);
     Assert.Greater(task.LastUpdateTime, old);
     //taskfolder
     old = task.LastUpdateTime;
     this.Idle();
     var folder = this.CreatePersonalTaskFolder(a);
     task.SetTaskFolder(folder);
     Assert.Greater(task.LastUpdateTime, old);
     old = task.LastUpdateTime;
     task.SetTaskFolder(folder);
     Assert.AreEqual(task.LastUpdateTime, old);
 }
예제 #6
0
        public void GetTags()
        {
            var account = this.CreateAccount();
            var task1 = new PersonalTask(account);
            task1.AddTag("程序设计");
            task1.AddTag(".NET");
            task1.AddTag("ASP.NET");
            task1.AddTag("001_Tag_001");
            task1.MarkAsCompleted();
            this._personalTaskService.Create(task1);
            var task2 = new PersonalTask(account);
            task2.AddTag("Mono");
            task2.AddTag(".net");
            task2.AddTag("JAVA");
            task1.AddTag("JAVA.NET");
            task2.AddTag("001_tag_001");
            this._personalTaskService.Create(task2);

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

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

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

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

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

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

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

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

            tasks = this._personalTaskService.GetIncompletedTasks(account, ".net");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains(".net", StringComparer.OrdinalIgnoreCase)));
            tasks = this._personalTaskService.GetIncompletedTasks(account, "java");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("java", StringComparer.OrdinalIgnoreCase)));
            tasks = this._personalTaskService.GetIncompletedTasks(account, "程序设计");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("程序设计", StringComparer.OrdinalIgnoreCase)));
            tasks = this._personalTaskService.GetIncompletedTasks(account, "Mono");
            Assert.AreEqual(1, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("Mono", StringComparer.OrdinalIgnoreCase)));
            tasks = this._personalTaskService.GetIncompletedTasks(account, "001_tag_001");
            Assert.AreEqual(0, tasks.Count());
            Assert.IsFalse(!tasks.All(x => x.Tags.Contains("001_tag_001", StringComparer.OrdinalIgnoreCase)));
        }
예제 #7
0
 public ActionResult Sync(string tasklistId, string taskFolderId, string changes, string by, string sorts)
 {
     //Fetch模式不支持同步变更
     Assert.IsFalse(this._fetchTaskHelper.IsFetchTaskFolder(taskFolderId ?? tasklistId));
     var folder = this.GetTaskFolder(taskFolderId ?? tasklistId);
     var a = this.Context.Current;
     return Json(this.Sync(changes, by, sorts
         , o => { }
         , () =>
         {
             var o = new PersonalTask(a);
             if (folder != null)
                 o.SetTaskFolder(folder);
             return o;
         }
         , (o, c) =>
         {
             var task = o as PersonalTask;
             //只有创建者才能更新个人任务
             Assert.AreEqual(task.CreatorAccountId, a.ID);
         }
         , () => folder == null
         , o => o
         , o => { folder.Settings[by] = o; this._taskFolderService.Update(folder); }));
 }
예제 #8
0
 void IPersonalTaskService.Delete(PersonalTask task)
 {
     _repository.Remove(task);
     if (this._log.IsInfoEnabled)
         this._log.InfoFormat("删除任务#{0}", task.ID);
 }
예제 #9
0
        private CooperTask CreateCooperTask(string subject, string body, DateTime? dueTime, bool isCompleted)
        {
            CooperTask task = new CooperTask(_account);

            task.SetSubject(subject);
            task.SetBody(body);
            task.SetDueTime(dueTime);
            if (isCompleted)
            {
                task.MarkAsCompleted();
            }
            else
            {
                task.MarkAsInCompleted();
            }
            task.SetPriority(Priority.Upcoming);

            _taskService.Create(task);

            return task;
        }
예제 #10
0
        private void AssertTaskAndExchangeTaskAreEqual(CooperTask cooperTask, ExchangeTask exchangeTask)
        {
            MicrosoftAssert.AreEqual(cooperTask.Subject, exchangeTask.Subject);
            MicrosoftAssert.AreEqual(cooperTask.Body, exchangeTask.Body.Text);
            MicrosoftAssert.AreEqual(cooperTask.DueTime, exchangeTask.DueDate);
            if (cooperTask.IsCompleted)
            {
                MicrosoftAssert.AreEqual(TaskStatus.Completed, exchangeTask.Status);
            }
            else
            {
                MicrosoftAssert.AreEqual(TaskStatus.InProgress, exchangeTask.Status);
            }

            MicrosoftAssert.AreEqual(cooperTask.Priority, ConvertToTaskPriority(exchangeTask.Importance));
            MicrosoftAssert.AreEqual(FormatTime(cooperTask.LastUpdateTime), FormatTime(exchangeTask.LastModifiedTime));
        }
예제 #11
0
 private void AssertTaskAndExchangeCalendarEventAreEqual(CooperTask cooperTask, Appointment appointment)
 {
     MicrosoftAssert.AreEqual(cooperTask.Subject, appointment.Subject);
     MicrosoftAssert.AreEqual(BodyType.Text, appointment.Body.BodyType);
     MicrosoftAssert.AreEqual(cooperTask.Body, appointment.Body.Text);
     MicrosoftAssert.AreEqual(cooperTask.DueTime.Value.Date, appointment.End.Date);
     MicrosoftAssert.AreEqual(FormatTime(cooperTask.LastUpdateTime), FormatTime(appointment.LastModifiedTime));
 }
예제 #12
0
 /// <summary>断言个人任务是否有效
 /// </summary>
 /// <param name="task"></param>
 public static void IsValid(Cooper.Model.Tasks.PersonalTask task)
 {
     Assert.IsValid(task as Cooper.Model.Tasks.Task);
     Assert.Greater(task.CreatorAccountId, 0);
 }
예제 #13
0
 void IPersonalTaskService.Update(PersonalTask task)
 {
     _repository.Update(task);
 }
예제 #14
0
 void IPersonalTaskService.Update(PersonalTask task)
 {
     _repository.Update(task);
 }
예제 #15
0
 /// <summary>
 /// 更新任务的最后更新时间
 /// </summary>
 private void UpdateTaskLastUpdateTime(CooperTask task, DateTime lastUpdateTime)
 {
     task.SetLastUpdateTime(lastUpdateTime);
     _taskService.Update(task);
 }
예제 #16
0
        public void TrashTaskTest()
        {
            var account = this.CreateAccount();
            var task = new PersonalTask(account);
            this._personalTaskService.Create(task);

            var taskId = task.ID;

            this.Evict(task);

            task = this._personalTaskService.GetTask(task.ID);
            task.MarkAsTrashed();
            this._personalTaskService.Update(task);

            this.Evict(task);

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

            var tasks = this._personalTaskService.GetTasks(account);
            Assert.AreEqual(0, tasks.Count());

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

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

            this.Evict(task);

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

            tasks = this._personalTaskService.GetTrashedTasks(account);
            Assert.AreEqual(0, tasks.Count());
        }
예제 #17
0
        public void UpdatePersonalTask()
        {
            var account = this.CreateAccount();
            var task = new PersonalTask(account);
            task.SetSubject(RandomString());
            task.SetBody(RandomString());
            task.SetPriority(Priority.Later);
            task.MarkAsCompleted();
            task.SetDueTime(DateTime.Now.AddDays(3));

            this._taskService.Create(task);

            this.Evict(task);

            var task2 = this._taskService.GetTask(task.ID) as PersonalTask;
            task2.SetSubject(task2.Subject + "updated");
            task2.SetBody(task2.Body + "updated");
            task2.SetPriority(Priority.Upcoming);
            task2.MarkAsInCompleted();
            task2.SetDueTime(DateTime.Now.AddDays(4));

            this._taskService.Update(task2);
            this.Evict(task2);
            var task3 = this._taskService.GetTask(task2.ID) as PersonalTask;

            Assert.AreEqual(task2.Subject, task3.Subject);
            Assert.AreEqual(task2.Body, task3.Body);
            Assert.AreEqual(task2.Priority, task3.Priority);
            Assert.AreEqual(FormatTime(task2.DueTime.Value), FormatTime(task3.DueTime.Value));
            Assert.AreEqual(task2.IsCompleted, task3.IsCompleted);
            Assert.AreEqual(task2.CreatorAccountId, task3.CreatorAccountId);
        }
예제 #18
0
        public void GetAll()
        {
            var a = this.CreateAccount();
            var folder = this.CreatePersonalTaskFolder(a);

            var task = new PersonalTask(a);
            this._personalTaskService.Create(task);

            task = new PersonalTask(a);
            task.SetTaskFolder(folder);
            this._personalTaskService.Create(task);

            task = new PersonalTask(a);
            task.SetTaskFolder(folder);
            this._personalTaskService.Create(task);

            Assert.AreEqual(3, this._personalTaskService.GetTasks(a).Count());
            Assert.AreEqual(2, this._personalTaskService.GetTasks(a, folder).Count());
            Assert.AreEqual(1, this._personalTaskService.GetTasksNotBelongAnyFolder(a).Count());
        }
예제 #19
0
 void IPersonalTaskService.Create(PersonalTask task)
 {
     _repository.Add(task);
     if (this._log.IsInfoEnabled)
         this._log.InfoFormat("新增任务#{0}|{1}|{2}", task.ID, task.Subject, task.CreatorAccountId);
 }