I have the following repository that I use for unit testing:
public class MyTestRepository<T>
{
private List<T> entities = new List<T>();
public IQueryable<T> Entities
{
get { return entities.AsQueryable(); }
}
public T New()
{
//return what here???
}
public void Create(T entity)
{
entities.Add(entity);
}
public void Delete(T entity)
{
entities.Remove(entity);
}
}
What do I return in the New() method?
I have tried this:
public T New()
{
return (T) new Object();
}
But that gives me the following exception when I run my unit test:
System.InvalidCastException: Unable to cast object of type 'System.Object' to type 'MyCustomDomainType'.
Any idea on how to implement the New() method?