Hi Ted, this looks like you've found a bug (a NullReferenceException inside a framework is always a bug in my eyes ;-) If tried to fix it - you can get a .Net4 version on https://github.com/alaendle/rhino-mocks/downloads - or just take a look at the most recent changeset.
Best regards, Andreas On 16 Jan., 14:29, Ted <[email protected]> wrote: > 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.
