예제 #1
0
        public void CanGetTheMovieTypeForAFilm()
        {
            var movieTypeGateway = new MovieTypeRetrieverSpy();
            var rentalGateway    = new InMemoryRentalGatewayDummy();
            var createRental     = new CreateRental(movieTypeGateway, rentalGateway);

            createRental.Execute(new CreateRentalRequest());

            movieTypeGateway.IsRetrieveCalled.Should().BeTrue();
        }
예제 #2
0
        public void CanSaveARental()
        {
            var movieTypeGateway = new MovieTypeRetrieverDummy();
            var rentalGateway    = new InMemoryRentalGatewaySpy();
            var createRental     = new CreateRental(movieTypeGateway, rentalGateway);

            createRental.Execute(new CreateRentalRequest());

            rentalGateway.IsSaveCalled.Should().BeTrue();
        }
예제 #3
0
        public void CanSaveARentalForRequestedMovieWithCost()
        {
            var movieTypeGateway = new MovieTypeRetrieverStub();
            var rentalGateway    = new InMemoryRentalGatewaySpy();
            var createRental     = new CreateRental(movieTypeGateway, rentalGateway);

            createRental.Execute(
                new CreateRentalRequest
            {
                MovieName = "Wonder Woman",
                Days      = 1
            }
                );

            rentalGateway.SaveArguments[1].Should().Be(2.0);
        }
        public void CanBuildAStatementForMultipleRegularRentals()
        {
            var movieTypeFactory = new MovieTypeFactory();
            var movieTypeGateway = new InMemoryMovieTypeGateway(movieTypeFactory);
            var rentalGateway    = new InMemoryRentalGateway();

            var createRental = new CreateRental(movieTypeGateway, rentalGateway);

            createRental.Execute(
                new CreateRentalRequest
            {
                MovieName = "Batman Begins",
                Days      = 1
            }
                );

            createRental.Execute(
                new CreateRentalRequest
            {
                MovieName = "The Dark Knight",
                Days      = 2
            }
                );

            createRental.Execute(
                new CreateRentalRequest
            {
                MovieName = "The Dark Knight Rises",
                Days      = 3
            }
                );

            var viewStatement = new ViewStatement(rentalGateway);

            var printStatement = new PrintStatement(viewStatement);

            var printStatementResponse = printStatement.Execute();

            printStatementResponse.Statement.Should().Be(
                "Rental Record for Customer\n" +
                "  Batman Begins 2.0\n" +
                "  The Dark Knight 2.0\n" +
                "  The Dark Knight Rises 3.5\n" +
                "You owe 7.5\n" +
                "You earned 3 frequent renter points"
                );
        }
예제 #5
0
        public void CanGetTheMovieTypeForRequestedFilm()
        {
            var movieTypeGateway = new MovieTypeRetrieverSpy();
            var rentalGateway    = new InMemoryRentalGatewayDummy();
            var createRental     = new CreateRental(movieTypeGateway, rentalGateway);

            const string movieName = "Man of Steel";

            createRental.Execute(
                new CreateRentalRequest
            {
                MovieName = movieName
            }
                );

            movieTypeGateway.RetrieveArguments[0].Should().Be(movieName);
        }
예제 #6
0
        public void CanSaveARentalForRequestedMovie()
        {
            var movieTypeGateway = new MovieTypeRetrieverDummy();
            var rentalGateway    = new InMemoryRentalGatewaySpy();
            var createRental     = new CreateRental(movieTypeGateway, rentalGateway);

            const string movieName = "Batman V Superman: Dawn of Justice";

            createRental.Execute(
                new CreateRentalRequest
            {
                MovieName = movieName
            }
                );

            rentalGateway.SaveArguments[0].Should().Be(movieName);
        }
예제 #7
0
        public void CanGetTheMovieTypeForRequestedNumberOfDays()
        {
            var movieTypeGateway = new MovieTypeRetrieverSpy();
            var rentalGateway    = new InMemoryRentalGatewayDummy();
            var createRental     = new CreateRental(movieTypeGateway, rentalGateway);

            const int days = 1;

            createRental.Execute(
                new CreateRentalRequest
            {
                Days = days
            }
                );

            movieTypeGateway.RetrieveArguments[1].Should().Be(days);
        }