Try this.
[Test]
public void injection_triggers_load()
{
    var facade = new Facade();
    var presenter = new TimeSheetPresenter(facade);

    var widget = MockRepository.GenerateMock<ITimeSheetMatrixWidget>();

    widget.Expect(w => w.Load(facade.Dtos));

    presenter.NonProjectActivityMatrix = widget;

    widget.VerifyAllExpectations();
}

On Sun, Jun 7, 2009 at 3:18 PM, Berryl Hesh <[email protected]> wrote:

>
> Hi Tim
>
> The trigger to satisfy the expectation is the injection of the widget
> into the presenter, as a property. Here is the relevant code for that:
>
>        public ITimeSheetMatrixWidget NonProjectActivityMatrix
>        {
>            set {
>                ... (validate & configure) ...
>
>                // load the activities
>                var dtos = Facade.NonProjectDtos;
>                _nonProjectActivityMatrix.Load(dtos);
>
>                ... (subscribe to events, etc)
>            }
>        }
>
> Here's a more (hopefully) succinct version of the problem test:
>
>        [Test]
>        public void Injection_Triggers_Load()
>         {
>            // set up presenter
>            var f = _getFacade();
>            var timeSheetPresenter = _getTimeSheetPresenter(f);
>
>            // inject the mocked widget
>            var widget =
> MockRepository.GenerateMock<ITimeSheetMatrixWidget>();
>             timeSheetPresenter.NonProjectActivityMatrix = widget; //
> <-- triggers the Load
>
>            widget.AssertWasCalled(x => x.Load(f.NonProjectDtos), mo
> => mo.IgnoreArguments());
>        }
>
> You'll notice that in this test I've just plain ignored the
> IEnumerable argument all together. It passes, proving the call to Load
> is made, but without being able to prove the Load was made with the
> right argument. There is an identical ITimeSheetMatrixWidget that the
> same presenter uses to display ProjectDtos, so it's worth bothering to
> nail the argument down in the tests.
>
> If I take off the IgnoreArguments option, then I'm back to the
> problems I originally described.
>
> Does this seem clearer?
>
> Thx,
> Berryl
>
>
>
> On Jun 7, 2:30 pm, Tim Barcz <[email protected]> wrote:
> > I guess I don't follow....I see the Expectation set up but then an
> immediate
> > verify (nothing done in the middle that would satisfy the expectation).
> >
> > Also not enough here to put in code and debug and make recommendations
> on.
> > Do you have a smaller sample with complete code?
> >
> > Tim
> >
> >
> >
> > On Sun, Jun 7, 2009 at 2:46 PM, Berryl Hesh <[email protected]> wrote:
> >
> > > I am trying to test that an IEnumerable used as an argument is
> > > correct, so far without success. When I try to use Arg<T>.Is.Equal
> > > (enum) Rhino displays what looks like the deferred execution of the
> > > IEnumerable:
> > > // Exception: Load(equal to TransferObjects.TimeSheetDtoAssembler
> > > +<ToActivityDtoCollection>d__1)
> >
> > > When I use Arg<T>.List.Equal(enum), Rhino displays the elements in the
> > > IEnumerable, all of which look correct.
> >
> > > Full test is below. Is this enough info to have an idea what the
> > > solution is?
> >
> > > Thank You
> >
> > > [Test]
> > >        public void OnInjection_Load_NonProjectDtos()
> > >        {
> > >            // set up presenter
> > >            var f = _getFacade();
> > >            var timeSheetPresenter = _getTimeSheetPresenter(f);
> >
> > >            // inject the mocked widget
> > >            var widget =
> > > MockRepository.GenerateMock<ITimeSheetMatrixWidget>();
> > >            timeSheetPresenter.NonProjectActivityMatrix = widget;
> >
> > >            Assert.That(f, Is.SameAs(timeSheetPresenter.Facade));
> > >            widget.Expect(x => x.Load
> > > (Arg<IEnumerable<DynamicDisplayDto>>.Is.Equal(f.NonProjectDtos)));
> >
> > >            widget.VerifyAllExpectations();
> > >        }
> >
> > --
> > Tim Barcz
> > ASPInsiderhttp://timbarcz.devlicio.ushttp://www.twitter.com/timbarcz
> >
>


-- 

Erma Bombeck <http://www.brainyquote.com/quotes/authors/e/erma_bombeck.html>
- "Never have more children than you have car windows."

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

Reply via email to