Say I have an interface that has as property another interface. Something like:
interface IOne
{
ITwo Two { get; set;}
}
And I create a mock for ITwo
and then create a mock for IOne
using Mock<ITwo>.Object
. How can I raise an event on ITwo
when I only have a reference to IOne
or Mock<IOne>
? I need a reference for Mock<ITwo>
, but how can I cast from ITwo
to Mock<ITwo>
? I hope it's clear :)
Thank you.
edit:
I hope this exampler is clearer:
interface IHuman
{
void Sneeze();
INose Nose { get; set;}
}
interface INose
{
event EventHandler Irritated;
}
class ToBeTested
{
private IHuman _human;
public ToBeTested(IHuman human)
{
_human = human;
_human.Nose.Irritated += NoseIrritated;
}
void NoseIrritated(object sender, EventArgs e)
{
_human.Sneeze();
}
}
I want to be able to access Mock from Mock. So I can do somethiong like:
noseMock.Raise(nose => nose.Irritated += null);
humanMock.Verify(human => human.Sneeze());