Esempio n. 1
0
        public void MapToTestWizardDto_TestTemplate_ValidDto()
        {
            //arrange
            var testTemplateId = 36;
            var testName       = "MyTest#1";
            var questionIds    = new int[] { 10, 11, 12 };
            var questions      = new List <Question>();

            foreach (var id in questionIds)
            {
                var question = new Question(id, "x", new WrittenAnswer("x", 1f), 1);
                questions.Add(question);
            }

            var testTemplate = new TestTemplate(testTemplateId, testName, 1, questions);

            var questionMapperMock = new Mock <IQuestionServiceMapper>();
            Expression <Func <IQuestionServiceMapper, Dtos.Wizard.QuestionDto> > setupExpression =
                x => x.MapToWizardQuestionDto(It.Is <Question>(q => questionIds.Contains(q.Id)));

            questionMapperMock
            .Setup(setupExpression)
            .Returns <Question>(x => new Dtos.Wizard.QuestionWithWrittenAnswerDto {
                Id = x.Id
            });

            //act
            var mapper = new TestServiceMapper(questionMapperMock.Object, new DateTimeProvider());
            var dto    = mapper.MapToTestWizardDto(testTemplate);

            //assert
            questionMapperMock.Verify(setupExpression, Times.Exactly(questionIds.Length));
            questionMapperMock.VerifyNoOtherCalls();
            dto.Name.Should().Be(testName);
        }
Esempio n. 2
0
 public TestReader(ReadOnlyAppDbContext dbContext, IQuestionServiceMapper questionMapper, TestServiceMapper testMapper, IDateTimeProvider dateTimeProvider)
 {
     this.dbContext        = dbContext;
     this.questionMapper   = questionMapper;
     this.testMapper       = testMapper;
     this.dateTimeProvider = dateTimeProvider;
 }
Esempio n. 3
0
 public TestOrchestrator(QuestionService questionService,
                         TestService testService,
                         GroupService groupService,
                         TestReader testReader,
                         TestServiceMapper testMapper,
                         IUserContext userContext,
                         IDateTimeProvider dateTimeProvider)
 {
     this.questionService  = questionService;
     this.testService      = testService;
     this.groupService     = groupService;
     this.testReader       = testReader;
     this.testMapper       = testMapper;
     this.userContext      = userContext;
     this.dateTimeProvider = dateTimeProvider;
 }
Esempio n. 4
0
 public TestMapperTests()
 {
     mapper = new TestServiceMapper(new QuestionServiceMapper(), new DateTimeProvider());
 }