public async Task DeleteById_ExistentTaskListId_Successful()
        {
            // Arrange.
            Seed(TripFlipDbContext, ValidUser);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberAdminRoleEntityToSeed);

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

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

            // Act.
            await taskListService.DeleteByIdAsync(existentTaskListId);

            var taskListEntity = await TripFlipDbContext
                                 .TaskLists
                                 .FindAsync(existentTaskListId);

            // Assert.
            Assert.IsNull(taskListEntity);
        }
Beispiel #2
0
        public async Task DeleteByIdAsync_GivenNotValidCurrentUser_ExceptionThrown(
            string displayName, ICurrentUserService currentUserService)
        {
            // Arrange.
            Seed(TripFlipDbContext, NonExistentUser);
            Seed(TripFlipDbContext, NotRouteSubscriberUser);
            Seed(TripFlipDbContext, NotTripSubscriberUser);

            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberAdminRoleEntityToSeed);

            CurrentUserService = currentUserService;

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

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.DeleteByIdAsync(validTaskListId), displayName);
        }
Beispiel #3
0
        public async Task DeleteByIdAsync_NonExistentTaskListId_ExceptionThrown()
        {
            // Arrange.
            var nonExistentTaskListId = 1;

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

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await taskListService.DeleteByIdAsync(nonExistentTaskListId));
        }
Beispiel #4
0
        public async Task DeleteByIdAsync_GivenCurrentUserNotRouteAdmin_ExceptionThrown()
        {
            // Arrange
            Seed(TripFlipDbContext, ValidUser);
            Seed(TripFlipDbContext, TripEntityToSeed);
            Seed(TripFlipDbContext, RouteEntityToSeed);
            Seed(TripFlipDbContext, TaskListEntityToSeed);
            Seed(TripFlipDbContext, TripSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteSubscriberEntitiesToSeed);
            Seed(TripFlipDbContext, RouteRoleEntitiesToSeed);

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

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

            // Act + Assert
            await Assert.ThrowsExceptionAsync <ArgumentException>(async() =>
                                                                  await taskListService.DeleteByIdAsync(validTaskListId));
        }