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.
--
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.