Ejemplo n.º 1
0
        public async Task <IActionResult> GetCourseDetails(string courseId)
        {
            var requestModel = new GetCourseDetailsRequestModel
            {
                UserId   = User.FindFirstValue(ClaimTypes.NameIdentifier),
                CourseId = courseId
            };

            var response = await _mediator.Send(requestModel);

            return(response.Course == null?
                   NotFound() :
                       Ok(response));
        }
Ejemplo n.º 2
0
        public async Task GetCourseDetailsQueryHandler_NoMyCourses_ReturnNull()
        {
            using var context = TestHelper.CreateInMemoryContext("GetCourseDetailsQueryHandler_NoMyCourses_ReturnNull");
            var profile = new MappingProfile();

            var config = new MapperConfiguration(cfg => {
                cfg.AddProfile <MappingProfile>();
            });
            var mapper = config.CreateMapper();

            var handler = new GetCourseDetailsQueryHandler(mapper, new UnitOfWork(context));
            var request = new GetCourseDetailsRequestModel
            {
                UserId   = Guid.NewGuid().ToString(),
                CourseId = "0"
            };

            var response = await handler.Handle(request, CancellationToken.None);

            response.Course.Should().BeNull();
        }