Note: The following are typically injected: IRepositoryProvider, IDataContextAsync, IDataContextAsync, IRepository, IRepositoryAsync vs. manually instantiated as they are in the code samples below.

private readonly IRepositoryProvider _repositoryProvider = new RepositoryProvider(new RepositoryFactories());

using (IDataContextAsync context = new NorthwindContext())
using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context, _repositoryProvider))
    IRepositoryAsync<Customer> customerRepository = new Repository<Customer>(context, unitOfWork);
    IService<Customer> customerService = new CustomerService(customerRepository);
    var customer = customerService.Find("ALFKI");
    TestContext.WriteLine("Customers found: {0}", customer.ContactName);
    Assert.AreEqual(customer.ContactName, "Maria Anders");

Last edited Nov 30, 2014 at 11:50 PM by lelong37, version 2