public void ReturnMovie(string movieTitle, string idNumber) { if (string.IsNullOrEmpty(movieTitle) || string.IsNullOrWhiteSpace(movieTitle)) { throw new EmptyMovieTitleException("Missing title."); } CheckIDFormat(idNumber); var rentalById = rentals.GetRentalsFor(idNumber); if (rentalById != null) { var rentalMovie = rentalById.Any(r => r.MovieTitle == movieTitle); //if (!rentals.GetRentalsFor(idNumber).Any(r => r.MovieTitle == movieTitle)) if (!rentalMovie) { throw new NotRegistratedRentalException($"{movieTitle} is not rented by {idNumber}."); } rentals.RemoveRental(movieTitle, idNumber); } else { throw new NotRegistratedRentalException($"{movieTitle} is not rented by {idNumber}."); } }
public void TrueIfAbleToReturnMovie() { //Arange sut.AddRental(TestMovie.Title, TestCustomer.SSN); //Act sut.RemoveRental(TestMovie.Title, TestCustomer.SSN); var rentals = sut.GetRentalsFor(TestCustomer.SSN); //Assert Assert.AreEqual(0, rentals.Count); }
public void ReturnMovie(string movieTitle, string socialSecurityNumber) { if (string.IsNullOrEmpty(movieTitle)) { throw new MovieException("Movie title is empty"); } checkSsnFormat(socialSecurityNumber); if (!Rentals.GetRentalsFor(socialSecurityNumber).Any(x => x.Movie.Equals(movieTitle))) { throw new RentalException("Need to be registered"); } if (!Movies.ContainsKey(movieTitle)) { throw new MovieException("Movie doesn't exit"); } Rentals.RemoveRental(movieTitle, socialSecurityNumber); }
public void ReturnMovie(int id, string movieTitle, string socialSecurityNumber) { rentals.RemoveRental(movieTitle, socialSecurityNumber); }