On Tue, Sep 30, 2008 at 6:15 AM, TrueWill <b
...@truewill.net> wrote:
> I'm working with the .Net 3.5 version of Rhino.Mocks 3.5 RC (I've got
> tentative management approval to use it), and am still trying to
> figure out some features.
> For the most part, I really like the new AAA syntax and the emphasis
> on stubs.
> 1. I read in Emanuele DelBono's thread that it will no longer be
> necessary to call Repeat.Any() on stubs. I'm assuming this didn't make
> it into the RC, correct? Particularly for read-only properties, it's
> painful to always write code like:
> thing.Stub(x => x.Name).Return("Bob").Repeat.Any();
> 2. Changing a stubbed return value later is still difficult, unless
> I'm doing something wrong. I tried TentativeReturn, which didn't
> appear to do anything. I want to be able to configure standard return
> values in a setup fixture, then customize a subset of these values in
> individual test cases. I can do it, but it's ugly:
> public interface ISomeThing
> {
> string Name { get; }
> }
> [Test]
> public void ReadOnlyPropertyChangeValueAfterRead()
> {
> ISomeThing thing = MockRepository.GenerateStub<ISomeThing>();
> thing.Stub(x => x.Name).Return("Bob").Repeat.Any();
> string previousValue = thing.Name;
> thing.BackToRecord();
> thing.Stub(x => x.Name).Return(previousValue + "
> Smith").Repeat.Any();
> thing.Replay();
> Assert.That(thing.Name, Is.EqualTo("Bob Smith"));
> }
> 3. I am still confused about the proper usage of Do. In Ayende's post
> (
> http://ayende.com/Blog/archive/2008/07/02/Rhino-Mocks-3.5-A-feature-t...
> ), he writes:
> .Do(invocation => Assert.AreEqual("foo", invocation.Arguments[0]));
> I don't get Arguments from IntelliSense. Say I have the following
> member of an interface:
> int GiveMeOneMore(int aValue);
> Can someone provide me a working code example of stubbing a return
> value that returns whatever the parameter is plus one?
> Thank you very much!