Created
March 2, 2009 22:44
-
-
Save mattpodwysocki/73041 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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