Hi!

I have the following codes and test. My expectation was, that this is
working, but it doesn't. Can anybody explain me why this constallation
does noch work? I get always the Exception

Rhino.Mocks.Exceptions.ExpectationViolationException:
Controller.ExceptionCatcher<System.Boolean>(System.Func`1[System.Boolean]);
Expected #1, Actual #0.

But I have defined an expectation for this call!


My Codes:


public interface ICommunicator
{
    event EventHandler IsConnected;
    bool Connect(string server);
    bool Disconnect();
    void SendMessage(string message);
}

public class Controller : IController
{
    private readonly ICommunicator communicator;
    private readonly IConfigurationSerialization
configurationSerialization;

    public Controller(ICommunicator communicator,
IConfigurationSerialization configurationSerialization)
    {
        this.communicator = communicator;
        this.configurationSerialization = configurationSerialization;

        communicator.IsConnected += Communicator_SendMessageSucceed;
    }

    internal void Communicator_SendMessageSucceed(object sender,
EventArgs e)
    {
        //do something
    }

    public void LoadConfiguration()
    {
        ExceptionCatcher(() => TryLoadConfiguration());
    }

    public virtual bool TryLoadConfiguration()
    {
        //do something
        return true;
    }

    public virtual T ExceptionCatcher<T>(Func<T> func)
    {
        try
        {
            return func();
        }
        catch (NotSupportedException ex)
        {
            //do special things
        }
        catch (Exception ex)
        {
            throw new Exception("unexpected error", ex);
        }

        return default(T);
    }
}

[Test]
public void The_Method_LoadConfiguration_Calls_All_Essential_Methods()
{
    //arange
    using (var controllerRepositoryMock =
MockRepository.GeneratePartialMock<Controller>(MockRepository.GenerateMock<ICommunicator>(),
 
MockRepository.GenerateMock<IConfigurationSerialization>()))
    {
        //act
        controllerRepositoryMock.LoadConfiguration();

        //assert
        controllerRepositoryMock.AssertWasCalled(c =>
c.ExceptionCatcher(() => true));
        controllerRepositoryMock.AssertWasCalled(c =>
c.TryLoadConfiguration());
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to