コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }