Exemplo n.º 1
0
        public void Answer_AcceptedAnswer_Successfully()
        {
            // Arrange
            var question          = new QuestionBuilder().SetupValidQuestion().Build();
            var target            = new AnswerBuilder().SetupValidAnswer(question).Build();
            var originalId        = target.Id;
            var originalUserId    = target.UserId;
            var originalBody      = target.Body;
            var originalCreatedOn = target.CreatedOn;
            var originalQuestion  = target.Question;

            // Act
            target.AcceptedAnswer();

            // Assert
            Assert.Equal(originalId, target.Id);
            Assert.Equal(originalUserId, target.UserId);
            Assert.Equal(originalBody, target.Body);
            Assert.Equal(originalCreatedOn, target.CreatedOn);
            Assert.True(target.IsAcceptedAnswer);
            Assert.True(DateTime.UtcNow - target.AcceptedOn < TimeSpan.FromSeconds(1));
        }
Exemplo n.º 2
0
        public void Answer_UndoAcceptedAnswer_Successfully()
        {
            // Arrange
            var question          = new QuestionBuilder().SetupValidQuestion().Build();
            var target            = new AnswerBuilder().SetupValidAnswer(question).Build();
            var originalId        = target.Id;
            var originalUserId    = target.UserId;
            var originalBody      = target.Body;
            var originalCreatedOn = target.CreatedOn;
            var originalQuestion  = target.Question;

            // Act
            target.AcceptedAnswer();
            target.UndoAcceptedAnswer();

            // Assert
            Assert.Equal(originalId, target.Id);
            Assert.Equal(originalUserId, target.UserId);
            Assert.Equal(originalBody, target.Body);
            Assert.Equal(originalCreatedOn, target.CreatedOn);
            Assert.False(target.IsAcceptedAnswer);
            Assert.Null(target.AcceptedOn);
        }