private static (GetLearningRepetitionQueryHandler handler, GetLearningRepetitionRequestModel request) CreateDependencies(ApplicationDbContext context, Guid userId, int courseId = 10)
        {
            var profile = new MappingProfile();
            var config  = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <MappingProfile>();
            });
            var mapper = config.CreateMapper();

            var repetitionManagerMock = new Mock <IRepetitionManager>();

            repetitionManagerMock
            .Setup(rm => rm.CreateRepetitionData(It.Is <WordStats>(ws => ws.Id == 30)))
            .Returns(("Question", null, null, null, RepetitionType.FromExampleToTranslatedOpen));

            var handler = new GetLearningRepetitionQueryHandler(new UnitOfWork(context),
                                                                mapper, repetitionManagerMock.Object, new Mock <IAudioService>().Object);

            var request = new GetLearningRepetitionRequestModel
            {
                CourseId = courseId,
                UserId   = userId.ToString()
            };

            return(handler, request);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetLearningRepetition(int courseId)
        {
            var requestModel = new GetLearningRepetitionRequestModel
            {
                CourseId = courseId,
                UserId   = User.FindFirstValue(ClaimTypes.NameIdentifier)
            };
            var response = await _mediator.Send(requestModel);

            return(Ok(response));
        }