public async Task GetAllByRouteIdAsync_GivenValidRouteId_Successful()
        {
            // Arrange
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntitiesToSeed);

            CurrentUserService = CreateCurrentUserService(ValidUser.Id, ValidUser.Email);

            var taskListService = new TaskListService(TripFlipDbContext,
                                                      Mapper, CurrentUserService);

            var    paginationDto = GetPaginationDto();
            string searchString  = null;
            var    comparer      = new TaskListDtoComparer();

            // Act
            var result = await taskListService.GetAllByRouteIdAsync(1,
                                                                    searchString, paginationDto);

            var returnedTaskListDtos = result.Items.ToList();

            var expectedTaskListCount = _expectedGotAllTaskListDtos.Count();

            // Assert
            Assert.AreEqual(expectedTaskListCount, result.TotalCount);

            for (var i = 0; i < expectedTaskListCount; i++)
            {
                Assert.AreEqual(0,
                                comparer.Compare(returnedTaskListDtos[i], _expectedGotAllTaskListDtos[i]));
            }
        }
예제 #2
0
        public async Task GetAllByRouteIdAsync_GivenInvalidRouteId_ExceptionThrown()
        {
            // Arrange
            Seed(TripFlipDbContext, TaskListEntitiesToSeed);

            CurrentUserService = CreateCurrentUserService(ValidUser.Id, ValidUser.Email);

            var taskListService = new TaskListService(TripFlipDbContext,
                                                      Mapper, CurrentUserService);
            var    invalidRouteId = 2;
            var    paginationDto  = GetPaginationDto();
            string searchString   = null;

            // Act + Assert
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.GetAllByRouteIdAsync(invalidRouteId,
                                                                                                             searchString, paginationDto));
        }