public async Task Test_CreateAsync_Given_Not_valid_CurrentUser_Data_Validation_should_be_failed() { Seed(TripFlipDbContext, UserEntityToSeed); Seed(TripFlipDbContext, TripRolesToSeed); var createTripDto = GetCreateTripDtoData(); // Reset CurrentUserService and TripService with non existent user. CurrentUserService = CreateCurrentUserServiceWithNonExistentUser(); TripService = new TripService(TripFlipDbContext, Mapper, CurrentUserService); await Assert.ThrowsExceptionAsync <NotFoundException>( () => TripService.CreateAsync(createTripDto)); }
public async Task Test_CreateAsync_Given_Valid_Data_validation_should_be_successful() { CurrentUserService = CreateCurrentUserServiceWithExistentUser(); TripService = new TripService(TripFlipDbContext, Mapper, CurrentUserService); Seed(TripFlipDbContext, UserEntityToSeed); Seed(TripFlipDbContext, TripRolesToSeed); var createTripDto = GetCreateTripDtoData(); var resultTripDto = await TripService.CreateAsync(createTripDto); var tripDtoComparer = new TripDtoComparer(); Assert.AreEqual(0, tripDtoComparer.Compare(resultTripDto, _expectedReturnTripDto)); }