Inheritance: IAssignedQuizDto
        public void Map_DtoToModel_Mapped()
        {
            var dto = new AssignedQuizDto
            {
                AssignmentId = 1,
                EndDate = DateTime.Now.AddDays(1),
                StartDate = DateTime.Now,
                Group = new GroupDto
                {
                    GroupNumber = 1,
                    Year = 2009
                },
                NumberOfQuestions = 10,
                Quiz = new QuizDto
                {
                    QuizId = 1
                }
            };

            var model = _mapper.Map(dto);

            Assert.NotNull(model);
            Assert.Equal(dto.StartDate, model.StartDate);
            Assert.Equal(dto.EndDate, model.EndDate);
            Assert.Equal(dto.NumberOfQuestions, model.NumberOfQuestions);
            Assert.Equal(dto.Group.GroupNumber, model.Group.GroupNumber);
            Assert.Equal(dto.Group.Year, model.Group.Year);
            Assert.Equal(dto.Quiz.QuizId, model.Quiz.QuizId);
        }
Exemplo n.º 2
0
        public void AssignQuizAsync_NotNullAssignment_Saved()
        {
            var assignments = A.Fake<IDbSet<AssignedQuizDto>>();
            var groups = new FakeDbSet<GroupDto> {new GroupDto {GroupId = 1, GroupNumber = 1, Year = 2009}};
            A.CallTo(() => _context.AssignedQuizes).Returns(assignments);
            A.CallTo(() => _context.Groups).Returns(groups);
            var assignment = new AssignedQuizDto {Group = new GroupDto {Year = 2014, GroupNumber = 1}};

            _quizRepository.AssignQuizAsync(assignment).Wait();

            A.CallTo(() => assignments.Add(assignment)).MustHaveHappened();
            A.CallTo(() => _context.SaveChangesAsync()).MustHaveHappened();
        }