public async Task FinishRentalOnGet_WhenEntityExistsAndIsRented_ReturnsRedirectToIndex() { //Arrange TestDbSeeder.Initialize(_db); TestDbSeeder.SeedBooks(_db); TestDbSeeder.SeedRentals(_db); //Act var bookId = 1; var result = await _controller.FinishRental(bookId); //Assert var book = await _db.Books.Include(b => b.Rentals).FirstOrDefaultAsync(b => b.Id == bookId); Assert.NotNull(book); Assert.Equal(Status.Available, book.Status); var lastRental = await _db.Rentals .Where(r => r.BookId == bookId) .OrderByDescending(r => r.BeginDate) .FirstOrDefaultAsync(); Assert.NotNull(lastRental); Assert.NotNull(lastRental.EndDate); var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Null(redirectToActionResult.ControllerName); Assert.Equal(nameof(RentalsController.AvailableBooks), redirectToActionResult.ActionName); }