예제 #1
0
        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}.");
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public void ReturnMovie(int id, string movieTitle, string socialSecurityNumber)
 {
     rentals.RemoveRental(movieTitle, socialSecurityNumber);
 }