Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

C# NSubstitude react to unsubsribe from event (operator -=)

I am trying to throw exception when unsubscribing from event.

.NET Framework 4.8

I tried this:

var sFE = NSubstitute.Substitute.For<System.Windows.FrameworkElement>();
sFE.When(x => x.SizeChanged -= Arg.Any<System.Windows.SizeChangedEventHandler>())
    .Do(x =>
{
    throw new System.MissingMethodException();
});

But I get error: System.ArgumentNullException: 'Value cannot be null. Parameter name: handler'

Please can you help me?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...