using System.Collections.Generic;
public class testProductCatalog
public readonly ProductActions Prodactions;
[TestCase(2, "ASP.Net Unleashed")]
public void SearchForProductIDInCatalog_ReturnsSuccess(int ProductID, string expectedresult)
Product testproduct = Prodactions.FindById(ProductID);
Assert.AreEqual(expectedresult, testproduct.Name);
public testProductCatalog()
IList<Product> products = new List<Product>
new Product { ProductId = 1, Name = "C# Unleashed", Description = "Short description here", Price = 49.99 },
new Product { ProductId = 2, Name = "ASP.Net Unleashed", Description = "Short description here", Price = 59.99 },
new Product { ProductId = 3, Name = "Silverlight Unleashed", Description = "Short description here", Price = 29.99 }
Mock<ProductActions> Prodactions = new Mock<ProductActions>();
Prodactions.Setup(mr => mr.FindById(It.IsAny<int>())).Returns((int i) => products.Where(x => x.ProductId == i).Single());
this.Prodactions = Prodactions.Object;
public class ProductCatalogRepository
public Product FindById(int ProductID)
throw new System.NotImplementedException();
public int ProductId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public double Price { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateModified { get; set; }
public interface ProductActions
public List<Product> FindAll();
public Product FindByName(string productName);
public Product FindById(int productId);
public static void Main()
var x = new NUnitLite.AutoRun().Execute(new string[]{"--test:testProductCatalog", "--noc"});
Console.WriteLine("----------------------------------------------");
Console.WriteLine(x==0?"All Test Passed... :¬)": string.Format("{0} tests failed... :¬(", x));
Console.WriteLine("----------------------------------------------");