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); }
public void GetIncompleted() { 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.MarkAsCompleted(); task.SetTaskFolder(folder); this._personalTaskService.Create(task); Assert.AreEqual(2, this._personalTaskService.GetIncompletedTasks(a).Count()); Assert.AreEqual(1, this._personalTaskService.GetIncompletedTasks(a, folder).Count()); Assert.AreEqual(1, this._personalTaskService.GetIncompletedTasksAndNotBelongAnyFolder(a).Count()); }
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))); }