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