public void GetFeaturedProductsWillReturnInstance() { // Fixture setup var fixture = new RepositoryFixture(); var sut = fixture.CreateAnonymous<ProductService>(); // Exercise system IEnumerable<DiscountedProduct> result = fixture.Get((IPrincipal user) => sut.GetFeaturedProducts(user)); // Verify outcome Assert.NotNull(result); // Teardown }
public void GetFeaturedProductsWillReturnInstance() { // Fixture setup var fixture = new RepositoryFixture(); var sut = fixture.CreateAnonymous <ProductService>(); // Exercise system IEnumerable <DiscountedProduct> result = fixture.Get((IPrincipal user) => sut.GetFeaturedProducts(user)); // Verify outcome Assert.NotNull(result); // Teardown }
public void GetFeaturedProductsWillReturnCorrectProductsForNonPreferredUser() { // Fixture setup var fixture = new RepositoryFixture(); var featuredProducts = fixture.CreateMany <Product>().ToList(); fixture.Register(() => { var repositoryStub = new Mock <ProductRepository>(); repositoryStub.Setup(r => r.GetFeaturedProducts()).Returns(featuredProducts); return(repositoryStub.Object); }); var expectedProducts = (from p in featuredProducts select new Likeness <Product, DiscountedProduct>(p)).ToList(); var sut = fixture.CreateAnonymous <ProductService>(); // Exercise system var result = fixture.Get((IPrincipal user) => sut.GetFeaturedProducts(user)); // Verify outcome Assert.True(expectedProducts.Cast <object>().SequenceEqual(result.Cast <object>())); // Teardown }
public void GetFeaturedProductsWillReturnCorrectProductsForNonPreferredUser() { // Fixture setup var fixture = new RepositoryFixture(); var featuredProducts = fixture.CreateMany<Product>().ToList(); fixture.Register(() => { var repositoryStub = new Mock<ProductRepository>(); repositoryStub.Setup(r => r.GetFeaturedProducts()).Returns(featuredProducts); return repositoryStub.Object; }); var expectedProducts = (from p in featuredProducts select new Likeness<Product, DiscountedProduct>(p)).ToList(); var sut = fixture.CreateAnonymous<ProductService>(); // Exercise system var result = fixture.Get((IPrincipal user) => sut.GetFeaturedProducts(user)); // Verify outcome Assert.True(expectedProducts.Cast<object>().SequenceEqual(result.Cast<object>())); // Teardown }