I am trying to mock a class with an indexer property
Here is the example of the code:
public interface IIndexer
{
string this[string index]
{
get;
}
}
[TestFixture]
public class TestApplication
{
private MockRepository m_Mocks;
[SetUp]
public void Setup()
{
m_Mocks = new MockRepository();
}
[Test]
public void CheckIndexer()
{
IIndexer indexerObj = m_Mocks.StrictMock<IIndexer>();
using (m_Mocks.Record())
{
Expect.Call(indexerObj["index1"]);
}
}
}
There is an exception when I'm calling to Expect.Call(indexerObj
["index1"]);
The exception is the following:
TestCase 'GSM.DataAccess.MDALAccess.Test.TestApplication.CheckIndexer'
failed: System.InvalidOperationException : Previous method
'IIndexer.get_Item("index1");' requires a return value or an exception
to throw.
at Rhino.Mocks.Impl.RecordMockState.AssertPreviousMethodIsClose()
at Rhino.Mocks.Impl.RecordMockState.MethodCall(IInvocation
invocation, MethodInfo method, Object[] args)
at Rhino.Mocks.MockRepository.MethodCall(IInvocation invocation,
Object proxy, MethodInfo method, Object[] args)
at Rhino.Mocks.Impl.RhinoInterceptor.Intercept(IInvocation
invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at IIndexerProxyc2c7135b1bea490d8bc099fa605d11c4.get_Item(String
index)
How I can mock the call IIndexer.get_Item("index1")?
Thanks
Slavik
--
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.