Reset mock verification in Moq?

前端 未结 8 1661
执笔经年
执笔经年 2021-02-11 12:01

Setup as so:

public interface IFoo
{
    void Fizz();
}

[Test]
public void A()
{
    var foo = new Mock(MockBehavior.Loose);

    foo.Object.Fizz();         


        
8条回答
  •  礼貌的吻别
    2021-02-11 12:40

    Addition to answer by @stackunderflow (haha, nice nick :))

    In later versions of Moq, Moq.MockExtensions.ResetCalls() was marked as obsolete. mock.Invocations.Clear() should be used instead:

    foo.Invocations.Clear();
    

提交回复
热议问题