Example #1
0
        public void QuestionAnswerShouldBeAnswered()
        {
            Question question = new Question(new User(), "Olá tudo bem?");
            question.Answer = "Sim, obrigado.";

            question.IsAnswered.Should().Be(true);
        }
Example #2
0
        public void QuestionMessageShouldBeInvalidWithMessage256()
        {
            char[] charArrayOverMaxLength = new char[MESSAGE_MAX_LENGTH + 1];
            for (int i = 0; i < MESSAGE_MAX_LENGTH + 1; i++)
                charArrayOverMaxLength[i] = '.';

            string messageOverMaxLength = new string(charArrayOverMaxLength);
            Question question = new Question(new User(), messageOverMaxLength);
        }
 public void GivenTheUserVintemHasTheFollowingQuestions(Table table)
 {
     _expectedQuestions = new List<Question>();
     foreach (var row in table.Rows)
     {
         var question = new Question(_currentUser, row["Question"]) { Answer = row["Answer"]};
         _expectedQuestions.Add(question);
     }
     _mock.Setup(x => x.AllAnsweredByUser(It.IsAny<string>())).Returns(_expectedQuestions);
 }
Example #4
0
        public ActionResult Index(string username, UserProfile profile)
        {
            var userProfile = Users.Load(user => user.Username == username);

            if (ModelState.IsValid)
            {
                Question newQuestion;
                if (Request.IsAuthenticated)
                {
                    User userFrom = Users.Load(user => user.Username == User.Identity.Name);
                    newQuestion = new Question(userFrom, userProfile, profile.NewQuestion);
                }
                else
                    newQuestion = new Question(userProfile, profile.NewQuestion);

                Questions.Add(newQuestion);
                Questions.Commit();
            }

            TempData["mensagem"] = Messages.QuestionPostedWithSuccess;
            return RedirectToAction("Index");
        }
Example #5
0
        public void QuestionObjectShouldBeDiff()
        {
            Question question1 = new Question(new User(), "Olá tudo bem?");
            Question question2 = new Question(new User(), "Olá tudo bem?");

            question1.Equals(question2).Should().Be(false);
        }
Example #6
0
        public void QuestionMessageShouldBeValidWithMessage255()
        {
            char[] charArrayMaxLength = new char[MESSAGE_MAX_LENGTH];
            for (int i = 0; i < MESSAGE_MAX_LENGTH; i++)
                charArrayMaxLength[i] = '.';

            string messageMaxLength = new string(charArrayMaxLength);
            Question question = new Question(new User(), messageMaxLength);

            question.Message.Length.Should().Be(MESSAGE_MAX_LENGTH);
        }
Example #7
0
 public void QuestionMessageShouldBeValid()
 {
     Question question = new Question(new User(), "Olá tudo bem?");
     question.Message.Should().Be("Olá tudo bem?");
 }
Example #8
0
 public void QuestionMessageShouldBeInvalidWhenToNull()
 {
     Question question = new Question(null, "Olá tudo bem?");
 }
Example #9
0
 public void QuestionMessageShouldBeInvalidWhenNull()
 {
     Question question = new Question(new User(), null);
 }
Example #10
0
 public void QuestionMessageShouldBeInvalidWhenEmpty()
 {
     Question question = new Question(new User(), "");
 }
Example #11
0
        public void QuestionAnswerShouldBeNotAnswered()
        {
            Question question = new Question(new User(), "Olá tudo bem?");

            question.IsAnswered.Should().Be(false);
        }
Example #12
0
 public void QuestionShouldNotBeAnonym()
 {
     User tiago = new User("Tiago");
     User vintem = new User("Vintem");
     Question question = new Question(vintem, tiago, "Olá tudo bem?");
     question.IsAnonymous.Should().Be(false);
 }
Example #13
0
 public void QuestionShouldBeToUserTiago()
 {
     User tiago = new User("Tiago");
     Question question = new Question(null, tiago, "Olá tudo bem?");
     question.To.Should().Be(tiago);
 }
Example #14
0
 public void QuestionShouldBeFromUserVintemToAnyUser()
 {
     User tiago = new User("Tiago");
     User vintem = new User("Vintem");
     Question question = new Question(vintem, tiago, "Olá tudo bem?");
     question.From.Should().Be(vintem);
 }
Example #15
0
 public void QuestionShouldBeAnonym()
 {
     User tiago = new User("Tiago");
     Question question = new Question(null, tiago, "Olá tudo bem?");
     question.IsAnonymous.Should().Be(true);
 }