Rhino Mocks IgnoreArguments () and testing if lambda was called correctly

Here is what I have:

   public interface IDataCenterMsmqWriter
   {
      void UpdateData(Action<DataCenterWcfProxy> action);
   }

Checked system:

public class WcfService : IWcfService
{
    private readonly IDataCenterMsmqWriter _writer;

    public WcfService(IDataCenterMsmqWriter writer)
    {
        _writer = writer;
    }

    #region IWcfService members

    public void SendData(SomeData data)
    {
        _writer.UpdateData(d => d.SendVarData(data));
    }

    // other members of IWcfService elided
    #endregion
}

How can I verify that Rhino Mocks defines _writer as Mock and wants to verify that the correct action was called in the UpdateData method.

I tried this:

// _writer is setup as a mock
var data = new SomeData();
_wcfServiceSUT.SendData(data);
_writer.AssertWasCalled(d => d.UpdateData(x => x.SendVarData(data));

does not work.

I can add:

p => p.IgnoreArguments () after UpdateData inside AssertWasCalled, but this does not give me what I want to call SendVarData with a data variable.

I looked at this:

How to claim that an action was triggered

but my action is not mocking like mockDialogService in his example.

Is there a way to check if the action or Func was called correctly with the correct input parameters, etc.?

+5
source share
2 answers

UpdateData , rhino mock

+1

, Action Func , ./a > . Google.

, , .

+1

All Articles