Invalid call, the last call has been used or no call has been made

后端 未结 5 979
夕颜
夕颜 2021-01-07 19:12

I am getting this error when I try to set a mock to have PropertyBehavior():

System.InvalidOperationException: System.InvalidOperationEx

5条回答
  •  长发绾君心
    2021-01-07 19:54

    I think you have to do MockRepository.ReplyAll() after you set up all expectations and before you start using this mock. So my guess in your case is that you have to move the Expect.Call line before mediator = new AddAddressMediator(form);, and stick the reply all right after that:

    [TestInitialize()]
    public void MyTestInitialize()
    {
        form = MockRepository.GenerateMock();
        // Make the properties work like a normal property
        Expect.Call(form.OKButtonEnabled).PropertyBehavior();
    
        //I tried this too.  I still get the exception
        //SetupResult.For(form.OKButtonEnabled).PropertyBehavior();
    
        MockRepository.ReplyAll();
        mediator = new AddAddressMediator(form);
    
    
    
    }
    

提交回复
热议问题