public void GetProductsTest() { // Arrange var categoryDao = MockRepository.GenerateMock<ICategoryDao>(); var productDao = MockRepository.GenerateMock<IProductDao>(); var categoryId = 1; var expected = new Product[] { new Product { Id = 1 }, new Product { Id = 3 }, }; productDao.Stub(o => o.Select(null)) .IgnoreArguments() .Return(expected); // Action Seven11ProductService target = new Seven11ProductService(categoryDao, productDao); var actual = target.GetProducts(categoryId).ToArray(); // Assertion productDao.AssertWasCalled(o => o.Select(Arg<ProductSelectArguments>.Matches(a => a.CategoryId == categoryId))); Assert.AreEqual(expected.Length, actual.Length); Assert.AreEqual(expected[0].Id, actual[0].Id); Assert.AreEqual(expected[1].Id, actual[1].Id); }
public void Update(Product entity) { Delete(entity); Insert(entity); }
public void Insert(Product entity) { throw new NotImplementedException(); }
public void Delete(Product entity) { throw new NotImplementedException(); }
public Product InsertProduct(Product product) { return product; }