Created
July 17, 2012 01:32
-
-
Save ferclaverino/3126348 to your computer and use it in GitHub Desktop.
Open closed example, step 1
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
[TestFixture] | |
class FilterTest | |
{ | |
[Test] | |
public void filterByBlue_return_2() | |
{ | |
// arrange | |
ProductFilter filter = new ProductFilter(); | |
IList<Product> products = BuildProducts(); | |
// act | |
var result = filter.ByColor(products, ProductColor.Blue); | |
// assert | |
Assert.That(result.Count(), Is.EqualTo(2)); | |
Assert.That(result, Has.All.Matches<Product>(x => x.Color == ProductColor.Blue)); | |
} | |
[Test] | |
public void filterBySmall_return_2() | |
{ | |
// arrange | |
ProductFilter filter = new ProductFilter(); | |
IList<Product> products = BuildProducts(); | |
// act | |
var result = filter.BySize(products, ProductSize.Small); | |
// assert | |
Assert.That(result.Count(), Is.EqualTo(2)); | |
Assert.That(result, Has.All.Matches<Product>(x => x.Size == ProductSize.Small)); | |
} | |
[Test] | |
public void filterByBlueAndSmall_return_1() | |
{ | |
// arrange | |
ProductFilter filter = new ProductFilter(); | |
IList<Product> products = BuildProducts(); | |
// act | |
var result = filter.ByColorAndSize(products, ProductColor.Blue, ProductSize.Small); | |
// assert | |
Assert.That(result.Count(), Is.EqualTo(1)); | |
Assert.That(result, Has.All.Matches<Product>(x => x.Size == ProductSize.Small)); | |
} | |
private IList<Product> BuildProducts() | |
{ | |
return new List<Product> { | |
new Product(ProductColor.Blue, ProductSize.Small), | |
new Product(ProductColor.Yellow, ProductSize.Small), | |
new Product(ProductColor.Yellow, ProductSize.Medium), | |
new Product(ProductColor.Red, ProductSize.Large), | |
new Product(ProductColor.Blue, ProductSize.ReallyBig) | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment