Beispiel #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);
        }
Beispiel #2
0
        public void MapToAnswer_QuestionWithChoiceAnswersDto_ValidAnswer(ChoiceAnswerType choiceAnswerType, bool allRequired)
        {
            //arrange
            var score = 5f;

            Dtos.Wizard.QuestionDto dto = new Dtos.Wizard.QuestionWithChoiceAnswersDto
            {
                Id = 1,
                ChoiceAnswerType        = choiceAnswerType,
                AllValidChoicesRequired = allRequired,
                Choices = new List <Dtos.Wizard.ChoiceDto>
                {
                    new Dtos.Wizard.ChoiceDto {
                        Content = "1", Valid = true
                    },
                    new Dtos.Wizard.ChoiceDto {
                        Content = "2", Valid = false
                    },
                },
                Categories = new List <int>(),
                Question   = "Question content",
                Score      = score
            };
            var expectedChoices = new List <Choice>
            {
                new Choice
                {
                    Content = "1",
                    Valid   = true
                },
                new Choice
                {
                    Content = "2",
                    Valid   = false
                }
            };
            var expectedAnswer = new ChoiceAnswer(expectedChoices, choiceAnswerType, score, allRequired);

            //act
            var mapper = new QuestionServiceMapper();
            var answer = mapper.MapToAnswer(dto);

            //assert
            answer.Should().BeEquivalentTo(expectedAnswer);
        }