You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to mock a IDummyRepository which implements IGenericRepository<TEntityKey, TEntity> interface, and need to verify a call for the Add method of IGenericRepository. But with the example code below I'm getting a MockException.
If I replace de IGenericRepository in the ServiceDummy for the IDummyRepository the test works, but not in the way I need.
This is a issue or am I doing something wrong?
Thanks and sorry for possible errors in my english.
[TestClass]
public class DummyServiceSpec
{
protected DummyService service;
protected DummyModel model;
[TestClass]
public class Work : DummyServiceSpec
{
[TestMethod]
public void ExpectToWork()
{
var repositoryMock = new Mock<IDummyRepository>();
var serviceDummy = new ServiceDummy(repositoryMock.Object);
var entity = new Dummy { DummyString = "DummyString" };
serviceDummy.Add(entity);
repositoryMock.Verify(r => r.Add(It.IsAny<Dummy>()), Times.AtLeastOnce());
}
}
}
public class ServiceDummy
{
protected IGenericRepository<Guid, Dummy> dummyRepository;
public ServiceDummy(IDummyRepository dummyRepository)
{
this.dummyRepository = dummyRepository;
}
public virtual void Add(Dummy entity)
{
this.dummyRepository.Add(entity);
}
}
The text was updated successfully, but these errors were encountered:
I'm trying to mock a IDummyRepository which implements IGenericRepository<TEntityKey, TEntity> interface, and need to verify a call for the Add method of IGenericRepository. But with the example code below I'm getting a MockException.
If I replace de IGenericRepository in the ServiceDummy for the IDummyRepository the test works, but not in the way I need.
This is a issue or am I doing something wrong?
Thanks and sorry for possible errors in my english.
The text was updated successfully, but these errors were encountered: