Category : Compilation
Level : Error
Check the Callback() method signatures for the SetupAdd() and SetupRemove() methods.
For example the following code is invalid:
[Fact]
public void RaiseTest()
{
var mock = new Mock<IWithEvent>(MockBehavior.Strict);
mock.SetupAdd(m => m.TheEvent += It.IsAny<EventHandler<string>>())
.Callback((string handler) =>
{
});
}
public interface IWithEvent
{
event EventHandler<string> TheEvent;
}
The following code should work:
[Fact]
public void RaiseTest()
{
var mock = new Mock<IWithEvent>(MockBehavior.Strict);
mock.SetupAdd(m => m.TheEvent += It.IsAny<EventHandler<string>>())
.Callback((EventHandler<string> handler) =>
{
});
}
public interface IWithEvent
{
event EventHandler<string> TheEvent;
}
Category : Compilation
Level : Error
Check the
Callback()method signatures for theSetupAdd()andSetupRemove()methods.For example the following code is invalid:
The following code should work: