I'd like to test my logic which expects three different interfaces. How can I unite these, because I can't use mock methods while I have three instances. I guess I did something very wrong with the repositories but I have no idea. Thank you for your help!
[Test]
public void TestThatLogicABCWorks()
{
Mock<IRepositoryA> mockInstance1 = new Mock<IRepositoryA>();
Mock<IRepositoryB> mockInstance2 = new Mock<IRepositoryB>();
Mock<IRepositoryC> mockInstance3 = new Mock<IRepositoryC>();
LogicABC logic = new LogicABC(mockInstance1.Object, mockInstance2.Object, mockInstance3.Object);
}
Edit: i have three entity classes, 1 general repository and three entity specific repos. In logic I make queries including all three entities, which I reach as:
public class LogicABC : ILogic
{
IRepository<A> ARepo; //generic repo
IRepository<B> BRepo;
IRepository<C> CRepo;
public LogicABC(IARepository ARepo, IBRepository BRepo, ICRepository CRepo)
{
this.ARepo = ARepo; //entity specific repos
this.BRepo = BRepo;
this.CRepo = CRepo;
}
public LogicABC()
{
var Entity = new ABCEntities(); //context
this.ARepo = new ARepository(Entity);
this.BRepo = new BRepository(Entity);
this.CRepo = new CRepository(Entity);
}
//queries
public List<int> Query1()
{
var q1 = from x in CRepo.GetAll()
select x.Id;
return q1.ToList();
}
I need to test these queries with mock. For example setup that logicABC.Query1() returns 1 and then verify it.