Hi Chris

Good spot that I'd laid out the test wrong the first time I wrote it
to this forum, without having the trigger after the expectation. I'd
realized that too, and had just used an AAA syntax version of it when
I'd responded to Tim.

I redid it your way just to make sure (below), and I get the same
problem where the argument is not evaluated sufficiently to be
verified. That the test passes when using IgnoreArguments proves the
call to the Load is being made.

At this point I'd settle for a test that would break if the argument
really was wrong, but I haven't figured out how to do that yet.

Thanks for the response, & cheers,
Berryl

[Test]
        public void ProjectMatrix_Injection_IsLoaded_TEMP()
        {
            _projectMatrix =
MockRepository.GenerateMock<ITimeSheetMatrixWidget>();
            _nonProjectMatrix =
MockRepository.GenerateStub<ITimeSheetMatrixWidget>();
            _totalMatrix =
MockRepository.GenerateStub<ITimeSheetMatrixWidget>();

               // ignoring the args is hack to compensate for
inability to validate IEnumerable without it
         _projectMatrix.Expect(x => x.Load(_facade.ProjectDtos)).Return
(_facade.ProjectDtos.Count()).IgnoreArguments();

            new MatrixEntryService(_facade, _projectMatrix,
_nonProjectMatrix, _totalMatrix);

            _projectMatrix.VerifyAllExpectations();
        }

On Jun 12, 4:37 pm, Chris Martin <[email protected]> wrote:
> 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