public async Task DeleteAsync_WithNullRequestId_ReturnsFalse() { // Arrange var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var ridesService = new RidesService(new EfRepository <Ride>(context), null, null, new EfRepository <Conversation>(context)); // Act var result = await ridesService.DeleteAsync(null); // Assert Assert.False(result); }
public async Task DeleteAsync_WithCorrectId_WorksCorrectly() { // Arrange var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var ride = new Ride { Title = "Ride Title", PhoneNumber = "0000000000", Notes = "Ride Notes", Car = new Car(), Date = DateTime.UtcNow, AvailableSeats = 1, From = "Test From", To = "Test To", Conversation = new Conversation() }; await context.Rides.AddAsync(ride); await context.SaveChangesAsync(); var ridesService = new RidesService(new EfRepository <Ride>(context), null, null, new EfRepository <Conversation>(context)); // Act var result = await ridesService.DeleteAsync(ride.Id); // Assert Assert.True(result); var rideExists = await context.Rides.AnyAsync(); Assert.False(rideExists); var conversationExists = await context.Conversations.AnyAsync(); Assert.False(conversationExists); }