The internal (non-public) events are not handled properly by JustMock, there is no indication for error, Raise arrangement simply does not working as expected. The following sample reproduces the issue:
namespace TestExample
{
public class ClassWithEvents
{
internal event EventHandler<EventArgs> InternalEventToTest;
}
[TestClass()]
public class EventTests
{
[TestMethod]
public void ClassWithEvents_InternalEventTest()
{
//Arrange
bool eventRaised = false;
ClassWithEvents classWithEvents = Mock.Create<ClassWithEvents>();
classWithEvents.InternalEventToTest += (object sender, EventArgs e) =>
{
eventRaised = true;
};
// Act
Mock.Raise(() => classWithEvents.InternalEventToTest += null, new EventArgs());
// Assert
Assert.IsTrue(eventRaised);
}
}
}