Created
August 29, 2010 18:04
-
-
Save chaliy/556506 to your computer and use it in GitHub Desktop.
BaseRepositoryStub.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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