[Test]public void Foo(){ var callback = Substitute.For<Action>(); callback(); Assert.That(callback.ReceivedCalls().Count(), Is.EqualTo(1));
var callbackNotCalled = Substitute.For<Action>(); Assert.That(callbackNotCalled.ReceivedCalls().Count(), Is.EqualTo(0));}
--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nsubstitute+unsubscribe@googlegroups.com.
To post to this group, send email to nsubs...@googlegroups.com.
Visit this group at https://groups.google.com/group/nsubstitute.
For more options, visit https://groups.google.com/d/optout.
Hi John,You should be able to do:callback.Received()(); // i.e. did it receive `callback()`Or the slightly less confusing:callback.Received().Invoke(); // callback() is equivalent to callback.Invoke()Regards,David
On Sat, May 26, 2018 at 3:10 AM, John B <john....@gmail.com> wrote:
I'm trying to check if a fake Action has been called, or not. Here's how I'm doing it:
[Test]public void Foo(){var callback = Substitute.For<Action>();callback();Assert.That(callback.ReceivedCalls().Count(), Is.EqualTo(1));var callbackNotCalled = Substitute.For<Action>();Assert.That(callbackNotCalled.ReceivedCalls().Count(), Is.EqualTo(0));}Is there a more readable solution? I was hoping to use Received() and DidNotReceive().
--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nsubstitute...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to nsubstitute+unsubscribe@googlegroups.com.