Я пытаюсь изучить и реализовать TDD, в частности, используя Moq, и я столкнулся с дизайном, который я не могу понять, как издеваться:
namespace RIACompletelyRelativeWebService.Web.Services
{
[EnableClientAccess]
public class AncestorDomainService : TableDomainService<AncestorEntityContext>
{
public AncestorDomainService()
{
//this.EntityContext = new AncestorEntityContext();
}
public IQueryable<AncestorEntity> GetAncestorEntities()
{
return this.EntityContext.AncestorEntities;
}
public void AddAncestorEntity(AncestorEntity entity)
{
this.EntityContext.AncestorEntities.Add(entity);
}
}
}
Я думаю, что мне нужно смоделировать TableDomainService, чтобы я мог проверить свою логику AncestorDomainService, не запуская Azure. Я устал примерно так:
public class AncestorDomainService<TEntityContext> : TableDomainService<TEntityContext> where TEntityContext is a TableEntityContext
Но TableDomainService не понравилось использование универсального. Я также попытался установить EntityContext, но он только для чтения. Я видел, как другие люди используют общий DomainService и шаблон проектирования Repository, но поскольку TableDomainService позволяет мне использовать таблицы Azure за кулисами, я думаю, что мне нужно придерживаться TableDomainService <>. Должен ли я просто подделать TableDomainService, TableEntityContext и TableEntitySet, который возвращается?