Step two – abstract the concrete class

Now that the interface is generic, we can start to work on the SpeakerRepository. First let's rename it to InMemorySpeakerRepository. Now, we want to start using generics. Create a new class, InMemoryRepository<T> and have the speaker repository inherit from it:

public abstract class InMemoryRepository<T> : IRepository<T>{  public abstract T Create(T speaker);  public abstract T Get(int id);  public abstract IQueryable<T> GetAll();  public abstract T Update(T speaker);  public abstract void Delete(T speaker);}

In order to move slow and have the tests passing as much as possible, we are using abstract and will have to have each method in the speaker repository override the base class methods. This gives us ...

Get Practical Test-Driven Development using C# 7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.