Ted
unread,Jan 16, 2012, 8:29:20 AM1/16/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino.Mocks
I've found what seems to be a bug. I have a stub on an interface with
an indexer. This test passes, as you'd expect:
public interface IIndexer
{
object this[string name] { get; }
}
[TestFixture]
public class MockTest
{
[Test]
public void ShouldPass()
{
IIndexer item = MockRepository.GenerateStub<IIndexer>();
Assert.IsNull(item[null]);
}
}
If I add a setter to the indexer the call fails, with a
NullReferenceException
public interface IIndexer
{
object this[string name] { get; set; }
}
[TestFixture]
public class MockTest
{
[Test]
public void ShouldFail()
{
IIndexer item = MockRepository.GenerateStub<IIndexer>();
Assert.IsNull(item[null]);
}
}
Now, if instead of passing in null I pass in a string, it passes
again:
public interface IIndexer
{
object this[string name] { get; set; }
}
[TestFixture]
public class MockTest
{
[Test]
public void ShouldPass()
{
IIndexer item = MockRepository.GenerateStub<IIndexer>();
Assert.IsNull(item["name"]);
}
}
Can Ayende or anyone shine any light on this strange behaviour?
Ted.