public void RemoveTag() { 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 == ";")); Assert.IsFalse(task.Tags.Any(x => x == "a")); 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")); task.RemoveTag(")"); task.RemoveTag(".Net"); task.RemoveTag("∮a∮bba"); task.RemoveTag("∮;∮ b"); task.RemoveTag(" A "); this._personalTaskService.Update(task); this.Evict(task); task = this._personalTaskService.GetTask(task.ID); Assert.AreEqual(3, 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 == "b")); 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 == "bb")); Assert.IsTrue(task.Tags.Any(x => x == "001_Tag_001")); }
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))); }