Skip to content

Instantly share code, notes, and snippets.

@chaliy
Created August 29, 2010 18:04
Show Gist options
  • Save chaliy/556506 to your computer and use it in GitHub Desktop.
Save chaliy/556506 to your computer and use it in GitHub Desktop.
BaseRepositoryStub.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Castle.MicroKernel;
using Castle.MicroKernel.Registration;
using Commons.DomainDesign.Model;
namespace Inventory.Tests.Stubs
{
public abstract class BaseRepositoryStub<TEntity, TRep> : IRegistration
where TEntity : RootAggregate
where TRep : class
{
private readonly IList<TEntity> _store = new List<TEntity>();
public IList<TEntity> Store
{
get { return _store; }
}
public TEntity GetByID(Guid id)
{
return _store.First(x => x.__PersistanceID == id);
}
public void Add(TEntity entity)
{
_store.Add(entity);
}
#region IRegistration Members
void IRegistration.Register(IKernel kernel)
{
kernel.Register(Component.For<TRep>().Instance(this as TRep));
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment