Skip to content

Instantly share code, notes, and snippets.

@yaplex
Created June 19, 2017 19:55
Show Gist options
  • Save yaplex/664193275f04824ac99620a889aaf173 to your computer and use it in GitHub Desktop.
Save yaplex/664193275f04824ac99620a889aaf173 to your computer and use it in GitHub Desktop.
[TestFixture]
public class ProductBLTests
{
[Test]
public void GetProductsTest()
{
MockRepository mocks = new MockRepository();
ProductDAL dal = (ProductDAL)mocks.StrictMock(typeof(ProductDAL));
using (mocks.Record())
{
List<Product> expectedProducts = new List<Product>();
Product p = new Product();
p.Name = "Dell Pc";
p.Id = 333;
expectedProducts.Add(p);
Expect.Call(dal.GetProducts()).Return(expectedProducts);
}
using (mocks.Playback())
{
ProductBL bl = new ProductBL(dal);
List<Product> products = bl.GetProducts();
Assert.AreEqual(1, products.Count);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment