When calling the Raise() or RaiseAsync() method, check the parameters send to the events.
Category : Compilation
Level : Error
For example, the following code is invalid, because the TheEvent expected two arguments (object and string).
[Fact]
public void RaiseTest()
{
var mock = new Mock<IWithEvent>(MockBehavior.Strict);
mock.Raise(m => m.TheEvent += null, null, 1234);
}
public interface IWithEvent
{
event EventHandler<string> TheEvent;
}
The following code is valid:
[Fact]
public void RaiseTest()
{
var mock = new Mock<IWithEvent>(MockBehavior.Strict);
mock.Raise(m => m.TheEvent += null, null, "1234");
}
public interface IWithEvent
{
event EventHandler<string> TheEvent;
}
This rule will prevent the issue devlooped/moq#1568 (and the related PR devlooped/moq#1571).
When calling the
Raise()orRaiseAsync()method, check the parameters send to the events.Category : Compilation
Level : Error
For example, the following code is invalid, because the
TheEventexpected two arguments (objectandstring).The following code is valid:
This rule will prevent the issue devlooped/moq#1568 (and the related PR devlooped/moq#1571).