public void PriceCodeSetter_OutOfRangeException_Under()
        {
            // arrange
            var movie = new Movie(string.Empty, Movie.Regular);

            // act
            movie.PriceCode = -1;
        }
        public void MovieCtor_TitleGetter()
        {
            // arrange
            string expectedTitle = "title";

            // act
            var movie = new Movie(expectedTitle, Movie.Regular);
            string actualTitle = movie.Title;

            // assert
            Assert.AreEqual<string>(expectedTitle, actualTitle);
        }
        public void RentalCtor_MovieGetter()
        {
            // arrange
            var expectedMovie = new Movie(string.Empty, Movie.Regular);

            // act
            var rental = new Rental(expectedMovie, 0);
            var actualMovie = rental.Movie;

            // assert
            Assert.AreEqual<Movie>(expectedMovie, actualMovie);
        }
        public void MovieCtor_PriceCodeGetter()
        {
            // arrange
            int expectedPriceCode = Movie.Regular;

            // act
            var movie = new Movie(string.Empty, expectedPriceCode);
            int actualPriceCode = movie.PriceCode;

            // assert
            Assert.AreEqual<int>(expectedPriceCode, actualPriceCode);
        }
        public void RentalCtor_DaysRentedGetter()
        {
            // arrange
            var movie = new Movie(string.Empty, Movie.Regular);
            int expectedDaysRented = 1;

            // act
            var rental = new Rental(movie, expectedDaysRented);
            int actualDaysRented = rental.DaysRented;

            // assert
            Assert.AreEqual<int>(expectedDaysRented, actualDaysRented);
        }
        public void GetFrequentRenterPoint_RegularMoreThan1Days()
        {
            // arrange
            var movie = new Movie(string.Empty, Movie.Regular);
            var rental = new Rental(movie, 2);
            int expectedFrequentRenterPoints = 1;

            // act
            int actualFrequentRenterPoints = rental.GetFrequentRenterPoints();

            // assert
            Assert.AreEqual<int>(expectedFrequentRenterPoints, actualFrequentRenterPoints);
        }
        public void GetFrequentRenterPoint_NewReleaseLessOrEqual1Days()
        {
            // arrange
            var movie = new Movie(string.Empty, Movie.NewRelease);
            var rental = new Rental(movie, 1);
            int expectedFrequentRenterPoints = 1;

            // act
            int actualFrequentRenterPoints = rental.GetFrequentRenterPoints();

            // assert
            Assert.AreEqual<int>(expectedFrequentRenterPoints, actualFrequentRenterPoints);
        }
        public void PriceCodeSetter_Getter()
        {
            // arrange
            var movie = new Movie(string.Empty, Movie.Regular);
            int expectedPriceCode = Movie.NewRelease;

            // act
            movie.PriceCode = expectedPriceCode;
            int actualPriceCode = movie.PriceCode;

            // assert
            Assert.AreEqual<int>(expectedPriceCode, actualPriceCode);
        }
        public void AddRental()
        {
            // arrange
            var movie = new Movie(string.Empty, Movie.Regular);
            var rental = new Rental(movie, 1);
            var customer = new Customer("equo");

            // act
            customer.AddRental(rental);

            // assert
            ;
        }
        public void HtmlStatement_ChildrensMoreThan3Days()
        {
            // arrange
            var customer = new Customer("equo");
            var movie = new Movie("fuga", Movie.Childrens);
            var rental = new Rental(movie, 4);
            customer.AddRental(rental);
            string expectedHtmlStatement =
                "<h1>Rentals for <em>equo</em></h1><p>" + "\n" +
                "fuga: 3<br>" + "\n" +
                "<p>You owe <em>3</em><p>" + "\n" +
                "On this rental you earned <em>1</em> frequent renter points<p>";

            // act
            string actualHtmlStatement = customer.HtmlStatement();

            // assert
            Assert.AreEqual<string>(expectedHtmlStatement, actualHtmlStatement);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            // declare movies
            var hoge    = new Movie("Hoge",     Movie.Regular);
            var piyo    = new Movie("Piyo",     Movie.Regular);
            var fuga    = new Movie("Fuga",     Movie.NewRelease);
            var hogera  = new Movie("Hogera",   Movie.Childrens);

            // declare customer
            var equo = new Customer("Equo");

            // rent movies
            equo.AddRental(new Rental(hoge,     1));
            equo.AddRental(new Rental(piyo,     3));
            equo.AddRental(new Rental(fuga,     2));
            equo.AddRental(new Rental(hogera,   4));

            // output statement
            Console.WriteLine(equo.Statement());
        }
Exemplo n.º 12
0
 public Rental(Movie movie, int daysRented)
 {
     this.movie = movie;
     this.daysRented = daysRented;
 }
        public void HtmlStatement_NewReleaseLessOrEqual1Days()
        {
            // arrange
            var customer = new Customer("equo");
            var movie = new Movie("piyo", Movie.NewRelease);
            var rental = new Rental(movie, 1);
            customer.AddRental(rental);
            string expectedHtmlStatement =
                "<h1>Rentals for <em>equo</em></h1><p>" + "\n" +
                "piyo: 3<br>" + "\n" +
                "<p>You owe <em>3</em><p>" + "\n" +
                "On this rental you earned <em>1</em> frequent renter points<p>";

            // act
            string actualHtmlStatement = customer.HtmlStatement();

            // assert
            Assert.AreEqual<string>(expectedHtmlStatement, actualHtmlStatement);
        }
        public void Statement_Sum()
        {
            // arrange
            var customer = new Customer("equo");
            var hoge    = new Movie("Hoge",     Movie.Regular);
            var piyo    = new Movie("Piyo",     Movie.Regular);
            var fuga    = new Movie("Fuga",     Movie.NewRelease);
            var hogera  = new Movie("Hogera",   Movie.Childrens);
            customer.AddRental(new Rental(hoge,     1));
            customer.AddRental(new Rental(piyo,     3));
            customer.AddRental(new Rental(fuga,     2));
            customer.AddRental(new Rental(hogera,   4));
            string expectedStatement =
                "Rental Record for equo" + "\n" +
                "\t" + "Hoge" + "\t" + "2" + "\n" +
                "\t" + "Piyo" + "\t" + "3.5" + "\n" +
                "\t" + "Fuga" + "\t" + "6" + "\n" +
                "\t" + "Hogera" + "\t" + "3" + "\n" +
                "Amount owed is 14.5" + "\n" +
                "You earned 5 frequent renter points";

            // act
            string actualStatement = customer.Statement();

            // assert
            Assert.AreEqual<string>(expectedStatement, actualStatement);
        }
        public void Statement_RegularMoreThan2Days()
        {
            // arrange
            var customer = new Customer("equo");
            var movie = new Movie("hoge", Movie.Regular);
            var rental = new Rental(movie, 3);
            customer.AddRental(rental);
            string expectedStatement =
                "Rental Record for equo" + "\n" +
                "\t" + "hoge" + "\t" + "3.5" + "\n" +
                "Amount owed is 3.5" + "\n" +
                "You earned 1 frequent renter points";

            // act
            string actualStatement = customer.Statement();

            // assert
            Assert.AreEqual<string>(expectedStatement, actualStatement);
        }
        public void Statement_NewReleasMoreThan1Days()
        {
            // arrange
            var customer = new Customer("equo");
            var movie = new Movie("piyo", Movie.NewRelease);
            var rental = new Rental(movie, 2);
            customer.AddRental(rental);
            string expectedStatement =
                "Rental Record for equo" + "\n" +
                "\t" + "piyo" + "\t" + "6" + "\n" +
                "Amount owed is 6" + "\n" +
                "You earned 2 frequent renter points";

            // act
            string actualStatement = customer.Statement();

            // assert
            Assert.AreEqual<string>(expectedStatement, actualStatement);
        }
        public void Statement_ChildrensMoreThan3Days()
        {
            // arrange
            var customer = new Customer("equo");
            var movie = new Movie("fuga", Movie.Childrens);
            var rental = new Rental(movie, 4);
            customer.AddRental(rental);
            string expectedStatement =
                "Rental Record for equo" + "\n" +
                "\t" + "fuga" + "\t" + "3" + "\n" +
                "Amount owed is 3" + "\n" +
                "You earned 1 frequent renter points";

            // act
            string actualStatement = customer.Statement();

            // assert
            Assert.AreEqual<string>(expectedStatement, actualStatement);
        }
        public void HtmlStatement_Sum()
        {
            // arrange
            var customer = new Customer("equo");
            var hoge = new Movie("Hoge", Movie.Regular);
            var piyo = new Movie("Piyo", Movie.Regular);
            var fuga = new Movie("Fuga", Movie.NewRelease);
            var hogera = new Movie("Hogera", Movie.Childrens);
            customer.AddRental(new Rental(hoge, 1));
            customer.AddRental(new Rental(piyo, 3));
            customer.AddRental(new Rental(fuga, 2));
            customer.AddRental(new Rental(hogera, 4));
            string expectedHtmlStatement =
                "<h1>Rentals for <em>equo</em></h1><p>" + "\n" +
                "Hoge: 2<br>" + "\n" +
                "Piyo: 3.5<br>" + "\n" +
                "Fuga: 6<br>" + "\n" +
                "Hogera: 3<br>" + "\n" +
                "<p>You owe <em>14.5</em><p>" + "\n" +
                "On this rental you earned <em>5</em> frequent renter points<p>";

            // act
            string actualHtmlStatement = customer.HtmlStatement();

            // assert
            Assert.AreEqual<string>(expectedHtmlStatement, actualHtmlStatement);
        }
        public void HtmlStatement_RegularMoreThan2Days()
        {
            // arrange
            var customer = new Customer("equo");
            var movie = new Movie("hoge", Movie.Regular);
            var rental = new Rental(movie, 3);
            customer.AddRental(rental);
            string expectedHtmlStatement =
                "<h1>Rentals for <em>equo</em></h1><p>" + "\n" +
                "hoge: 3.5<br>" + "\n" +
                "<p>You owe <em>3.5</em><p>" + "\n" +
                "On this rental you earned <em>1</em> frequent renter points<p>";

            // act
            string actualHtmlStatement = customer.HtmlStatement();

            // assert
            Assert.AreEqual<string>(expectedHtmlStatement, actualHtmlStatement);
        }