public void ToQuestionDtoList_ReturnsCorrectTypeAndNumberOfElements()
        {
            var choiceQuestion = TestQuestionFactory.ChoiceQuestion();
            var numricQuestion = TestQuestionFactory.NumericQuestion();
            var dateQuestion   = TestQuestionFactory.DateQuestion();

            var questions = new List <Question> {
                choiceQuestion,
                numricQuestion,
                dateQuestion
            };

            var result = ProductMapper.ToQuestionDtoList(questions);

            var resultChoiceQuestion  = result?.First(r => r.QuestionCode == choiceQuestion.Code);
            var resultNumericQuestion = result?.First(r => r.QuestionCode == numricQuestion.Code);
            var resultDateQuestion    = result?.First(r => r.QuestionCode == dateQuestion.Code);

            Assert.NotNull(result);
            Assert.NotEmpty(result);
            Assert.Equal(questions.Count, result.Count);
            Assert.NotNull(resultChoiceQuestion);
            Assert.IsType <ChoiceQuestionDto>(resultChoiceQuestion);
            Assert.NotNull(resultNumericQuestion);
            Assert.IsType <NumericQuestionDto>(resultNumericQuestion);
            Assert.NotNull(resultDateQuestion);
            Assert.IsType <DateQuestionDto>(resultDateQuestion);
        }
        public void ShouldReturnTheSameNumber()
        {
            TestQuestionFactory factory = new TestQuestionFactory();
            Question = new Model.Question();
            Question.PredefinedAnswers = new List<PredefinedAnswer>();
            pre1 = new PredefinedAnswer();
            pre2 = new PredefinedAnswer();
            pre1.Id = 1;
            pre1.Text = "Ja";
            pre2.Id = 2;
            pre2.Text = "Nee";
            Question.PredefinedAnswers.Add(pre1);
            Question.PredefinedAnswers.Add(pre2);

            answer1 = new UserAnswer();
            answer2 = new UserAnswer();
            answer3 = new UserAnswer();
            answer1.PredefinedAnswer_Id = pre1.Id;
            answer2.PredefinedAnswer_Id = pre2.Id;
            answer3.PredefinedAnswer_Id = pre1.Id;

            foreach (PredefinedAnswer item in Question.PredefinedAnswers)
            {
                Question.PredefinedAnswerCount++;
            }

            Assert.AreEqual(Question.PredefinedAnswerCount, 3);
        }
        public void Product_QuestionsAreAdded()
        {
            var product = TestProductFactory.EmptyTravel();

            var testQuestions = new List <Question>
            {
                TestQuestionFactory.ChoiceQuestion(),
                TestQuestionFactory.DateQuestion(),
                TestQuestionFactory.NumericQuestion()
            };

            product.AddQuestions(testQuestions);

            Assert.NotEmpty(product.Questions);
            Assert.Equal(testQuestions.Count, product.Questions.Count);
            Assert.All(product.Questions, item => Assert.NotEqual(Guid.Empty, item.Id));
        }
        public void ToQuestionDtoList_ReturnsCorrectValue()
        {
            var choiceQuestion = TestQuestionFactory.ChoiceQuestion();

            var questions = new List <Question> {
                choiceQuestion
            };

            var result         = ProductMapper.ToQuestionDtoList(questions);
            var resultQuestion = result?.First(r => r.QuestionCode == choiceQuestion.Code) as ChoiceQuestionDto;

            Assert.NotNull(result);
            Assert.NotEmpty(result);
            Assert.NotNull(resultQuestion);

            Assert.Equal(choiceQuestion.Index, resultQuestion.Index);
            Assert.Equal(choiceQuestion.Text, resultQuestion.Text);
            Assert.NotNull(resultQuestion.Choices);
            Assert.Equal(choiceQuestion.Choices.Count, resultQuestion.Choices.Count);
        }