So I have recreated something similar to your setup
public class Something
{
private readonly IIndex<string, IService> index;
public Something(IIndex<string, IService> index)
{
this.index = index;
}
public void DoStuff()
{
this.index["someString"].Send();
}
}
public interface IIndex<TKey, TValue>
{
TValue this[TKey index] {get;set;}
}
public interface IService
{
void Send();
}
And then test like so (using Moq):
// Arrange
var serviceMock = new Mock<IService>();
var indexMock = new Mock<IIndex<string, IService>>();
indexMock.Setup(x => x[It.IsAny<string>()]).Returns(serviceMock.Object);
var something = new Something(indexMock.Object);
// Act
something.DoStuff();
// Assert
serviceMock.Verify(x => x.Send());
Hopefully this will point you in the right direction. Obviously you will need to Mock your IRepo<Notification>
.