I’m building mvc3 application that should serve about 1000-2000 concurrent users,
I implemented Castle Active Record and simple repository pattern, now i need to unit test all this that it won’t crash on concurrency and in multi-thread environment like iis.
How should I do it?
I’m using nunit testing framework.
My Repository:
//interface
public interface IAbstractRepository<T> where T : class
{
void Create(T model);
void Update(T model);
void Delete(T model);
int Count();
T FindById(object id);
T FindOne(params ICriterion[] criteria);
IList<T> FindAll();
IList<T> FindAllByCriteria(params ICriterion[] criteria);
}
//concrete implementation
public class AbstractRepository<T> : IAbstractRepository<T> where T : class
{
void IAbstractRepository<T>.Create(T model)
{
ActiveRecordMediator<T>.Save(model);
}
void IAbstractRepository<T>.Update(T model)
{
ActiveRecordMediator<T>.Update(model);
}
void IAbstractRepository<T>.Delete(T model)
{
ActiveRecordMediator<T>.Delete(model);
}
int IAbstractRepository<T>.Count()
{
return ActiveRecordMediator<T>.Count();
}
T IAbstractRepository<T>.FindById(object id)
{
return ActiveRecordMediator<T>.FindByPrimaryKey(id);
}
T IAbstractRepository<T>.FindOne(params ICriterion[] criteria)
{
return ActiveRecordMediator<T>.FindOne(criteria);
}
IList<T> IAbstractRepository<T>.FindAll()
{
return ActiveRecordMediator<T>.FindAll();
}
IList<T> IAbstractRepository<T>.FindAllByCriteria(params ICriterion[] criteria)
{
return ActiveRecordMediator<T>.FindAll(criteria);
}
}
That’s no longer a unit test what you are trying to do. It’s a load test. There are some tools out there that allow you to record some scenario and then simulate concurrent access to your web application executing this scenario: