Exemple #1
0
        public void MapToWizardQuestionDto_QuestionWithChoiceAnswers_ValidDto(ChoiceAnswerType choiceAnswerType, bool allRequired)
        {
            //arrange
            var choices     = GetChoices();
            var question    = GetQuestion(choiceAnswerType, choices, allRequired);
            var expectedDto = new Dtos.Wizard.QuestionWithChoiceAnswersDto
            {
                Id      = question.Id,
                Choices = ((ChoiceAnswer)question.Answer)
                          .Choices.Select(x => new Dtos.Wizard.ChoiceDto {
                    Content = x.Content, Valid = x.Valid
                })
                          .ToList(),
                AllValidChoicesRequired = allRequired,
                ChoiceAnswerType        = choiceAnswerType,
                Question   = question.Content,
                Score      = question.Answer.MaxScore,
                Categories = new List <int>()
            };

            //act
            var mapper = new QuestionServiceMapper();
            var dto    = mapper.MapToWizardQuestionDto(question);

            //assert
            dto.Should().BeEquivalentTo(expectedDto);
        }
Exemple #2
0
        public void MapToWizardQuestionDto_QuestionWithWrittenAnswers_ValidDto()
        {
            //arrange
            var expectedDto = new Dtos.Wizard.QuestionWithWrittenAnswerDto
            {
                Id         = questionWithWrittenAnswer.Id,
                Answer     = ((WrittenAnswer)questionWithWrittenAnswer.Answer).Value,
                Question   = questionWithWrittenAnswer.Content,
                Score      = questionWithWrittenAnswer.Answer.MaxScore,
                Categories = new List <int>()
            };

            //act
            var mapper = new QuestionServiceMapper();
            var dto    = mapper.MapToWizardQuestionDto(questionWithWrittenAnswer);

            //assert
            dto.Should().BeEquivalentTo(expectedDto);
        }