public void AddComment_Can_Remove_Multiple_Comments_To_Existing_Thread() { // Arrange Forum forum = new Forum(); DateTime currentDateTime = DateTime.Now; Person person = new Person("Bas", ERole.Lead); Task task = new Task("Sample Task", person); const string name = "ThreadOne title."; Thread thread = new Thread(name, currentDateTime, person, task); Person personTwo = new Person("Tom", ERole.Developer); const string contentCommentOne = "This is a test comment one."; Person personThree = new Person("Jan", ERole.Developer); const string contentCommentTwo = "This is a test comment two."; Comment commentOne = new Comment(thread, personTwo, currentDateTime, contentCommentOne); Comment commentTwo = new Comment(thread, personThree, currentDateTime, contentCommentTwo); // Act forum.NewThread(thread); thread.AddComment(commentOne); thread.AddComment(commentTwo); thread.DeleteComment(commentOne); thread.DeleteComment(commentTwo); // Assert Assert.Contains(thread, forum.GetThreads()); Assert.DoesNotContain(commentOne, thread.GetComments()); Assert.DoesNotContain(commentTwo, thread.GetComments()); }
public void NewThread_Cant_Add_Multiple_Empty_Comments_On_Thread_Throw_ArgumentNullException() { // Arrange Forum forum = new Forum(); DateTime currentDateTime = DateTime.Now; Person person = new Person("Bas", ERole.Lead); Task task = new Task("Sample Task", person); const string name = "ThreadOne title."; Thread thread = new Thread(name, currentDateTime, person, task); Person personTwo = new Person("Tom", ERole.Developer); const string contentCommentOne = ""; Person personThree = new Person("Jan", ERole.Developer); const string contentCommentTwo = ""; Comment commentOne = new Comment(thread, personTwo, currentDateTime, contentCommentOne); Comment commentTwo = new Comment(thread, personTwo, currentDateTime, contentCommentTwo); // Act forum.NewThread(thread); // Assert Assert.DoesNotContain(commentOne, thread.GetComments()); Assert.Throws <ArgumentNullException>(() => thread.AddComment(commentOne)); Assert.DoesNotContain(commentTwo, thread.GetComments()); Assert.Throws <ArgumentNullException>(() => thread.AddComment(commentTwo)); }
public void NewThread_Cant_Add_Comment_On_Thread_State_Done_Throw_NotSupportedException() { // Arrange Forum forum = new Forum(); DateTime currentDateTime = DateTime.Now; Person person = new Person("Bas", ERole.Lead); Task task = new Task("Sample Task", person); const string name = "ThreadOne title."; Thread thread = new Thread(name, currentDateTime, person, task); Person personTwo = new Person("Tom", ERole.Developer); const string contentCommentOne = "ThreadOne title."; Comment commentOne = new Comment(thread, personTwo, currentDateTime, contentCommentOne); // Act forum.NewThread(thread); task.NextState(); task.NextState(); // Assert Assert.DoesNotContain(commentOne, thread.GetComments()); Assert.Throws <NotSupportedException>(() => thread.AddComment(commentOne)); }
public ActionResult Reply(int id, string comment, HubColor color) { if (User.IsInRole("Banned")) { return(HttpNotFound());// banned users can't post replies. } Thread thread = db.Threads.Find(id); if (thread == null) { System.Diagnostics.Debug.WriteLine("nulled"); return(HttpNotFound()); } thread.AddComment(db, new Models.Hub.Comment(User.Identity.Name, comment, color)); TempData["thread"] = thread.Id; return(RedirectToAction("Details")); }