public void Answer_EditingWithInvalidData_FailsValidation(string userId, string body) { // Arrange - Build Answer var question = new QuestionBuilder().SetupValidQuestion().Build(); var target = new AnswerBuilder().SetupValidAnswer(question).Build(); var limits = new LimitsBuilder().Build(); var user = new UserBuilder().BuildUser(new Guid(userId)).Build(); // Act, Assert Assert.Throws <BusinessException>(() => target.Edit(user, body, limits)); }
public void Answer_EditingOutsideDeadline_Fails() { // Arrange - Build Answer, 1 minute after deadline. var limits = new LimitsBuilder().Build(); var question = new QuestionBuilder().SetupValidQuestion().Build(); var target = new AnswerBuilder() .SetupValidAnswer(question) .MakeTimeGoBy() .Build(); // Arrange - Edit Data string editedBody = "BodyNormal"; // Act Assert.Throws <BusinessException>(() => target.Edit(target.User, editedBody, limits)); }
public void Answer_EditingWithValidDataWithinDeadline_Successfully() { // Arrange - Build Question var question = new QuestionBuilder().SetupValidQuestion().Build(); var target = new AnswerBuilder() .SetupValidAnswer(question) .Build(); var userId = target.UserId; // Arrange - Edit Data string editedBody = "BodyNormal"; var limits = new LimitsBuilder().Build(); // Act target.Edit(target.User, editedBody, limits); var result = target; // Assert Assert.NotEqual(default(Guid), result.Id); Assert.Equal(userId, result.UserId); Assert.Equal(editedBody, result.Body); Assert.Empty(result.Comments); }