I want to test that a method is called on the inner interface, how would I do such a thing with moq? Given the following example, I expect Z.Joy() to invoke Ix.Method().
interface Ix { void Method(); }
interface Iy<T> {}
class Z {
public Z (Iy<Ix> y) {}
public void Joy() {}
}
[TestClass]
public class Test {
[TestMethod]
public void ATest() {
var x = new Mock<Ix>();
var y = new Moxk<Iy<Ix>>(); // how can I pass x.Object?
var z = new Z(y.Object);
x.Verify(() => x.Method());
z.Joy();
}
}
Because you are mocking the interface
Iy<T>you will have to place a expectation or setup on methods on that mocked interface that deal withIx. I would expect you have something like this inIy<T>.So here you can.
and somewhere in
z.Joy()you will callx.SomeMethod()