Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created March 2, 2009 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/73041 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/73041 to your computer and use it in GitHub Desktop.
[Fact]
public void TestSpecificationCollection()
{
var minCredit = 3;
var product = new Product() { MinimumCreditRating = minCredit, Price = 50 };
var spec = new EligibleForDiscountSpecification(product);
var customers = new List<Customer>()
{
new Customer() {CreditRating = minCredit-2}, // bad credit
new Customer() {CreditRating = minCredit-1}, // bad credit
new Customer() {CreditRating = minCredit} // good credit
};
var eligible = from customer in customers
where spec.IsSatisfiedBy(customer)
select customer;
Assert.True(eligible.All(c => c.CreditRating >= minCredit));
Assert.Equal(1, eligible.Count());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment