本文整理汇总了C#中Customer.AddRental方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.AddRental方法的具体用法?C# Customer.AddRental怎么用?C# Customer.AddRental使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.AddRental方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HtmlStatement_WhenHavingMoviesFromDifferentCategories_ShouldGetAppropriateStatement
public void HtmlStatement_WhenHavingMoviesFromDifferentCategories_ShouldGetAppropriateStatement()
{
// Arrange
var customer = new Customer() { Name = "John Doe" };
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Skyfall", PriceCode = new NewReleasePrice() },
DaysRented = 1
});
customer.AddRental(new Rental
{
Movie = new Movie { Title = "The Lord Of The Rings", PriceCode = new RegularPrice() },
DaysRented = 1
});
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Brave", PriceCode = new ChildrenPrice() },
DaysRented = 1
});
// Act
string statement = customer.HtmlStatement();
// Assert
Assert.That(statement, Is.EqualTo("<h1>Rental Record for <em>John Doe</em>.</h1>" +
"<p><ul><li>Skyfall : 3$</li><li>The Lord Of The Rings : 2$</li><li>Brave : 1.5$</li></ul></p>" +
"<p>Amount owed is 6.5$.</p><p>You earned 3 frequent renter points.</p>"));
}
示例2: XMLStatementShouldBeValid
public void XMLStatementShouldBeValid()
{
var customer = new Customer("Test Customer");
var regularMovie = new Movie("RegularMovie", 0);
var childMovie = new Movie("ChildMovie", 2);
var newReleaseMovie = new Movie("NewRelease", 1);
customer.AddRental(new Rental(regularMovie, 2));
customer.AddRental(new Rental(childMovie, 3));
customer.AddRental(new Rental(newReleaseMovie, 1));
customer.AddRental(new Rental(newReleaseMovie, 3));
Assert.AreEqual(GetExpectedXMLStatement(),
customer.XmlStatement());
}
示例3: StatementTest
public void StatementTest()
{
var customer = new Customer("Test Customer");
var regularMovie = new Movie("RegularMovie", 0);
var childMovie = new Movie("ChildMovie", 2);
var newReleaseMovie = new Movie("NewRelease", 1);
customer.AddRental(new Rental(regularMovie, 2));
customer.AddRental(new Rental(childMovie, 3));
customer.AddRental(new Rental(newReleaseMovie, 1));
customer.AddRental(new Rental(newReleaseMovie, 3));
string expected = GetExpectedStatement();
string actual = customer.Statement();
Assert.AreEqual(expected, actual);
}
示例4: ManyMovies_ReturnsCorrectStatement
public void ManyMovies_ReturnsCorrectStatement()
{
Customer customer1 = new Customer("David");
Movie movie1 = new Movie("Madagascar", Movie.Childrens);
Rental rental1 = new Rental(movie1, 6); // 6 day rental
Movie movie2 = new Movie("Star Wars", Movie.NewRelease);
Rental rental2 = new Rental(movie2, 2); // 2 day rental
Movie movie3 = new Movie("Gone with the Wind", Movie.Regular);
Rental rental3 = new Rental(movie3, 8); // 8 day rental
customer1.AddRental(rental1);
customer1.AddRental(rental2);
customer1.AddRental(rental3);
string expected = "Rental Record for David\n" +
"\tMadagascar\t6.0\n" +
"\tStar Wars\t6.0\n" +
"\tGone with the Wind\t11.0\n" +
"Amount owed is 23.0\n" +
"You earned 4 frequent renter points";
string statement = customer1.Statement();
Assert.AreEqual(expected, statement);
}
示例5: ChildrensMovie_ReturnsCorrectStatement
public void ChildrensMovie_ReturnsCorrectStatement()
{
Customer customer2 = new Customer("Sallie");
Movie movie1 = new Movie("Madagascar", Movie.Childrens);
Rental rental1 = new Rental(movie1, 3); // 3 day rental
customer2.AddRental(rental1);
string expected = "Rental Record for Sallie\n" +
"\tMadagascar\t1.5\n" +
"Amount owed is 1.5\n" +
"You earned 1 frequent renter points";
string statement = customer2.Statement();
Assert.AreEqual(expected, statement);
}
示例6: NewReleaseMovie_ReturnsCorrectStatement
public void NewReleaseMovie_ReturnsCorrectStatement()
{
Customer customer2 = new Customer("Sallie");
Movie movie1 = new Movie("Star Wars", Movie.NewRelease);
Rental rental1 = new Rental(movie1, 3); // 3 day rental
customer2.AddRental(rental1);
string expected = "Rental Record for Sallie\n" +
"\tStar Wars\t9.0\n" +
"Amount owed is 9.0\n" +
"You earned 2 frequent renter points";
string statement = customer2.Statement();
Assert.AreEqual(expected, statement);
}
示例7: RegularMovie_ReturnsCorrectStatement
public void RegularMovie_ReturnsCorrectStatement()
{
Customer customer2 = new Customer("Sallie");
Movie movie1 = new Movie("Gone with the Wind", Movie.Regular);
Rental rental1 = new Rental(movie1, 3); // 3 day rental
customer2.AddRental(rental1);
string expected = "Rental Record for Sallie\n" +
"\tGone with the Wind\t3.5\n" +
"Amount owed is 3.5\n" +
"You earned 1 frequent renter points";
string statement = customer2.Statement();
Assert.AreEqual(expected, statement);
}
示例8: Statement_WhenHavingAChildrenMovieForTwoDays_ShouldProduceAppropriateStatement
public void Statement_WhenHavingAChildrenMovieForTwoDays_ShouldProduceAppropriateStatement()
{
// Arrange
var customer = new Customer { Name = "John Doe" };
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Cars", PriceCode = new ChildrenPrice() },
DaysRented = 2
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo("Rental Record for John Doe.\n\tCars\t1.5$\nAmount owed is 1.5$.\nYou earned 1 frequent renter points."));
}
示例9: Statement_WhenHavingAChildrenMovieForMoreThanThreeDays_ShouldPenalizeWithOneAndAHalfDollarsPerExtraDay
public void Statement_WhenHavingAChildrenMovieForMoreThanThreeDays_ShouldPenalizeWithOneAndAHalfDollarsPerExtraDay(int daysRented, string amountOwed)
{
// Arrange
var customer = new Customer { Name = "John Doe" };
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Cars", PriceCode = new ChildrenPrice() },
DaysRented = daysRented
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo(string.Format("Rental Record for John Doe.\n\tCars\t{0}\nAmount owed is {0}.\nYou earned 1 frequent renter points.", amountOwed)));
}
示例10: Statement_WhenHavingANewReleaseMovieForADay_ShouldProduceAppropriateStatement
public void Statement_WhenHavingANewReleaseMovieForADay_ShouldProduceAppropriateStatement()
{
// Arrange
var customer = new Customer() {Name = "John Doe"};
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Skyfall", PriceCode = new NewReleasePrice()},
DaysRented = 1
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo("Rental Record for John Doe.\n\tSkyfall\t3$\nAmount owed is 3$.\nYou earned 1 frequent renter points."));
}
示例11: Statement_WhenHavingTwoNormalMovies_ShouldGetTwoFrequentRenterPoints
public void Statement_WhenHavingTwoNormalMovies_ShouldGetTwoFrequentRenterPoints()
{
// Arrange
var customer = new Customer { Name = "John Doe" };
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Johnny Mnemonic", PriceCode = new RegularPrice() },
DaysRented = 1
});
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Terminator 2", PriceCode = new RegularPrice() },
DaysRented = 1
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo("Rental Record for John Doe.\n\tJohnny Mnemonic\t2$\n\tTerminator 2\t2$\nAmount owed is 4$.\nYou earned 2 frequent renter points."));
}
示例12: Statement_WhenHavingTwoNewReleaseMovies_ShouldGetTwoFrequentRenterPoints
public void Statement_WhenHavingTwoNewReleaseMovies_ShouldGetTwoFrequentRenterPoints()
{
// Arrange
var customer = new Customer() { Name = "John Doe" };
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Skyfall", PriceCode = new NewReleasePrice() },
DaysRented = 1
});
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Prometheus", PriceCode = new NewReleasePrice() },
DaysRented = 1
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo("Rental Record for John Doe.\n\tSkyfall\t3$\n\tPrometheus\t3$\nAmount owed is 6$.\nYou earned 2 frequent renter points."));
}
示例13: Statement_WhenHavingTwoChildrenMovies_ShouldGetTwoFrequentRenterPoints
public void Statement_WhenHavingTwoChildrenMovies_ShouldGetTwoFrequentRenterPoints()
{
// Arrange
var customer = new Customer { Name = "John Doe" };
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Cars", PriceCode = new ChildrenPrice() },
DaysRented = 1
});
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Cars 2", PriceCode = new ChildrenPrice() },
DaysRented = 1
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo("Rental Record for John Doe.\n\tCars\t1.5$\n\t" +
"Cars 2\t1.5$\nAmount owed is 3$.\nYou earned 2 frequent renter points."));
}
示例14: Statement_WhenHavingMoviesFromDifferentCategories_ShouldGetAppropriateStatement
public void Statement_WhenHavingMoviesFromDifferentCategories_ShouldGetAppropriateStatement()
{
// Arrange
var customer = new Customer() { Name = "John Doe" };
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Skyfall", PriceCode = new NewReleasePrice() },
DaysRented = 1
});
customer.AddRental(new Rental
{
Movie = new Movie { Title = "The Lord Of The Rings", PriceCode = new RegularPrice() },
DaysRented = 1
});
customer.AddRental(new Rental
{
Movie = new Movie { Title = "Brave", PriceCode = new ChildrenPrice()},
DaysRented = 1
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo("Rental Record for John Doe.\n\tSkyfall\t3$\n\tThe Lord Of The Rings\t2$\n\tBrave\t1.5$\nAmount owed is 6.5$.\nYou earned 3 frequent renter points."));
}
示例15: Statement_WhenHavingANormalMovieForADay_ShouldProduceAppropriateStatement
public void Statement_WhenHavingANormalMovieForADay_ShouldProduceAppropriateStatement()
{
// Arrange
var customer = new Customer {Name = "John Doe"};
customer.AddRental(new Rental
{
Movie = new Movie {Title = "Johnny Mnemonic", PriceCode = new RegularPrice()},
DaysRented = 1
});
// Act
string statement = customer.Statement();
// Assert
Assert.That(statement, Is.EqualTo("Rental Record for John Doe.\n\tJohnny Mnemonic\t2$\nAmount owed is 2$.\nYou earned 1 frequent renter points."));
}