Hi Karol,
I am not sure I understand your question. When you say it is "invoking like original method", do you mean the Producer.Send() method?
public void Send(Message message)
{
IMessage msg =_producer.CreateXmlMessage(message);
_producer.Send(msg);
}
This method is on a real (not substituted) class, so this method will be invoked normally and call CreateXmlMessage(...) and Send(msg) on the _producer substitute you passed into the constructor.
In that case I would expect both the assertions in your test (under "//verify") to pass.
If it helps, you could make the mocked call more explicit by writing the test like this:
[Test]
public void SendProducedMessage() {
//Arrange (set up all the substitutes)
var messageProducer = Substitute.For<IMessageProducer>();
var message = Substitute.For<Message>();
var producedMessage = Substitute.For<ITextMessage>();
messageProducer.CreateXmlMessage(message).Returns(producedMessage);
//Act (call real method)
var subject = new Producer(producerProxy);
subject.Send(message);
//Assert (real method called Send on the IMessageProducer substitute)
messageProducer.Received().Send(producedMessage);
}
Hope this helps.
Regards,