pencilCake
pencilCake

Reputation: 53243

How do I assert this method call by AssertWasCalled without testing the method parameters?

I want to check whether LogNotInRange method is called and I want to ignore testing with what method parameters it was called; I am just interested if LogNotInRange was called or not.

What is the correct Rhino Mocks syntax for it (I gave what I have been trying below:) ?

[TestMethod]
        public void MyTestMethod()
        {
            var logger = MockRepository.GenerateMock<ILogManager>();
            var teleporter = new Teleporter() {LogEventManager = logger};
            var message = new message() {IsDone = false};

            teleporter.Teleport(message);

            // How should I specify parameter1 and parameter2?
            logger.AssertWasCalled(t => t.LogNotInRange(parameter1, parameter2));
        }



public void LogNotInRange (object parameter1, object parameter2)
{
    // some logging logic
}

Upvotes: 1

Views: 916

Answers (2)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174299

Use Arg<T>.Is.Anything:

logger.AssertWasCalled(t => t.LogNotInRange(Arg<object>.Is.Anything, 
                                            Arg<object>.Is.Anything));

Upvotes: 2

Brian Low
Brian Low

Reputation: 11811

logger.AssertWasCalled(t => t.LogNotInRange(null, null), options => options.IgnoreArguments);

Upvotes: 1

Related Questions