// TODO: routing tdk konsisten ada yang lengkap routingnya, tp ada jg yang null? : DONE public async Task <IActionResult> GetLessonAll( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "Lesson/GetAll")] HttpRequest req, [SwaggerIgnore] ILogger log) { try { var data = await _lessonService.GetLessonAll(); var list = new List <LessonDTO>(); if (data == null) { return(new NotFoundObjectResult("Data is Empty!!!")); } var dataDTO = _mapper.Map <List <LessonDTO> >(data); return(new OkObjectResult(dataDTO)); } catch (Exception ex) { return(new BadRequestObjectResult(ex.Message)); } }
public async Task GetLessonAll_Success() { var repo = new Mock<IDocumentDBRepository<Lesson>>(); repo.Setup(c => c.GetAsync( It.IsAny<Expression<Func<Lesson, bool>>>(), It.IsAny<Func<IQueryable<Lesson>, IOrderedQueryable<Lesson>>>(), It.IsAny<Expression<Func<Lesson, Lesson>>>(), It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<Dictionary<string, string>>() )).Returns(Task.FromResult(new PageResult<Lesson>(lessonList, ""))); var svc = new LessonService(repo.Object); // act var actual = await svc.GetLessonAll(); // assert Assert.Equal(lessonList, actual); }