public void RentMovie(string customermane, string movietile) { Customer thec = Customers.Find(x => x.Customer_name.Equals(customermane)); if (thec == null) { throw new CustomerDoseNotExistExeption(); } Movie them = Stock.FirstOrDefault(y => y.Title.Equals(movietile)); if (them == null) { throw new MovieDoseNotExistExeption(); } List <Rental> custrentals = Rentals.GetRentalsFor(thec.socialSecurityNumber); if (custrentals.Count == 3) { throw new NoMoreThan3Exeption(); } foreach (Rental r in custrentals) { if (r.Movie_Title.Equals(movietile)) { throw new No2CoppiesForRenting(); } } Rentals.AddRental(movietile, thec.socialSecurityNumber); }
public void TrueIfAbleToAddRental() { sut.AddRental("Die hard", "19880606"); var rentals = sut.GetRentalsFor("19880606"); Assert.AreEqual(1, rentals.Count); }
public void CanAddRental() { sut.AddRental("Amelie", "1975-11-07"); sut.AddRental("Vukk", "1975-11-07"); var result = sut.GetRentalsFor("1975-11-07"); Assert.That(result.Count == 2); }
public void TrueIfIRentalsRunsRemoveRentalWhenReturnMovie() { rentals.GetRentalsFor(Arg.Any <string>()).Returns(new List <Rental>() { new Rental(DateTime.Now, TestMovie.Title, TestCustomer.SSN) }); AddCustomer_AddMovie(); sut.RentMovie(TestMovie.Title, TestCustomer.SSN); sut.ReturnMovie(TestMovie.Title, TestCustomer.SSN); rentals.Received(1).RemoveRental(Arg.Any <string>(), Arg.Any <string>()); }
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 CanReturnRental() { sut.RegisterCustomer("Dalius", "1920-01-01"); sut.AddMovie(movie); sut.RentMovie("Rambo", "1920-01-01"); sut.ReturnMovie("Rambo", "1920-01-01"); rentals.Received().RemoveRental("Rambo", "1920-01-01"); Assert.AreEqual(0, rentals.GetRentalsFor("1920-01-01").Count); }
public void TrueIfAbleToAddRental() { sut.AddRental(TestMovie.Title, TestCustomer.SSN); var rentals = sut.GetRentalsFor(TestCustomer.SSN); Assert.AreEqual(1, 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); }