Yeah, guid & ints have their value equality.SortExpression is not, I assume
On Mon, Dec 8, 2008 at 6:51 AM, Blair <[EMAIL PROTECTED]> wrote:
>
> Hi Ayende,
>
> Here was the expection I was getting.
>
> Just checking this is the error you would have expected.
>
> Rhino.Mocks.Exceptions.ExpectationViolationException:
> IProjectService.SelectProjectFacilityLists(c5ede8b0-ee9e-40b1-
> aa3f-46325264d600, 1, 10,
> SD.LLBLGen.Pro.ORMSupportClasses.SortExpression); Expected #0, Actual
> #1.
> IProjectService.SelectProjectFacilityLists(c5ede8b0-ee9e-40b1-
> aa3f-46325264d600, 1, 10,
> ISortExpressionProxy6a44599a5fc246c1a19346d670c55e83); Expected #1,
> Actual #0.
>
>
> On Dec 8, 12:34 pm, Blair <[EMAIL PROTECTED]> wrote:
> > Your the man.
> > Thanks mate.
> >
> > On Dec 8, 12:29 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> >
> > > yes
> >
> > > On Sun, Dec 7, 2008 at 10:26 PM, Blair <[EMAIL PROTECTED]>
> wrote:
> >
> > > > Thanks this makes a little more sense now. I'll go over my tests and
> > > > make sure that this is the reason they are requiring the constraints.
> > > > So you use constrainsts as a fall back to make sure the parameters
> > > > match when equal fails right?
> >
> > > > On Dec 8, 12:23 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> > > > > Yes, and yes.
> >
> > > > > On Sun, Dec 7, 2008 at 10:20 PM, Blair <[EMAIL PROTECTED]
> >
> > > > wrote:
> >
> > > > > > So what you are saying is that when you compare items which have
> > > > > > expectations on them internally in the Rhino Mocks framework you
> use
> > > > > > equals method to check if they are the same and fall back to
> object
> > > > > > references if method not overriden?
> >
> > > > > > Fair point. Is this in the Rhino Mocks documentation??
> >
> > > > > > Is what I said above correct?
> >
> > > > > > On Dec 8, 12:16 pm, Blair <[EMAIL PROTECTED]> wrote:
> > > > > > > Here is a test with constraints can you see any differences....
> >
> > > > > > > [Test]
> > > > > > > public void
> >
> > > >
> ActivityListing_LoadFacilities_ShouldCallSelectActivitiesMethodOnActivityService
> > > > > > > ()
> > > > > > > {
> > > > > > > //Create mock objects
> > > > > > > MockRepository mockRepository = new
> MockRepository();
> > > > > > > IActivityListingView view =
> > > > > > > mockRepository.Stub<IActivityListingView>();
> > > > > > > IActivityListService activityListService =
> > > > > > > mockRepository.StrictMock<IActivityListService>();
> > > > > > > IActivityService activityService =
> > > > > > > mockRepository.StrictMock<IActivityService>();
> > > > > > > IRedirector redirector =
> mockRepository.Stub<IRedirector>
> > > > > > > ();
> > > > > > > IRelationPredicateBucket bucket =
> > > > > > > mockRepository.Stub<IRelationPredicateBucket>();
> > > > > > > ISortExpression sortExpression =
> > > > > > > mockRepository.Stub<ISortExpression>();
> >
> > > > > > > ///SUT
> > > > > > > ActivityListingPresenter presenter = new
> > > > > > > ActivityListingPresenter(view, activityListService,
> activityService,
> > > > > > > redirector);
> >
> > > > > > > //Setup empty bag for test
> > > > > > > EntityBag<ActivityListEntity> entityBag = new
> > > > > > > EntityBag<ActivityListEntity>
> > > > > > > {
> > > > > > >
> Bag =
> > > > > > > new EntityCollection<ActivityListEntity>
> >
> > > > > > > {
> >
> > > > > > > new ActivityListEntity
> >
> > > > > > > {
> >
> > > > > > > Id = Guid.NewGuid(),
> >
> > > > > > > Name = "Item A"
> >
> > > > > > },
> >
> > > > > > > new ActivityListEntity
> >
> > > > > > > {
> >
> > > > > > > Id = Guid.NewGuid(),
> >
> > > > > > > Name = "Item B"
> >
> > > > > > }
> >
> > > > > > },
> > > > > > >
> Count =
> > > > > > > 5
> > > > > > > };
> >
> > > > > > > //Setup results for stub
> > > > > > > view.IndustrialCodeName = string.Empty;
> > > > > > > view.SortExpression = String.Empty;
> > > > > > > view.MaxRows = 10;
> > > > > > > view.StartRow = 0;
> > > > > > >
> SetupResult.For(view.Identity).Return(Guid.NewGuid());
> >
> > > > > > > //Setup expectations
> > > > > > > Expect.Call(activityListService.SelectActivities
> > > > > > > (view.StartRow, view.MaxRows, bucket, sortExpression))
> > > > > > > .Constraints(Is.Equal(0), Is.Equal(10),
> Is.TypeOf
> > > > > > > (typeof(IRelationPredicateBucket)), Is.TypeOf(typeof
> > > > > > > (ISortExpression)))
> > > > > > > .Return(entityBag);
> >
> > > > > > > //Move into replay mode
> > > > > > > mockRepository.ReplayAll();
> >
> > > > > > > //Call method for SUT
> > > > > > > presenter.LoadFacilities();
> >
> > > > > > > //Verify expectations
> > > > > > > mockRepository.VerifyAll();
> > > > > > > }
> >
> > > > > > > On Dec 8, 12:10 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> >
> > > > > > > > Probably because the method that isn't using the prefetch is
> using
> > > > the
> > > > > > > > parameters value equality to fix things.While the prefetch
> doesn't
> > > > > > override
> > > > > > > > Equals, so we are forced to compare using references, which
> are
> > > > > > obviously
> > > > > > > > not the same
> >
> > > > > > > > On Sun, Dec 7, 2008 at 10:05 PM, Blair <
> [EMAIL PROTECTED]
> >
> > > > > > wrote:
> >
> > > > > > > > > It just seems a little strange as if I use another method
> without
> > > > the
> > > > > > > > > prefetch path parameter I do not need the constrainsts. Let
> me
> > > > digg
> > > > > > up
> > > > > > > > > the test case and show you what I mean. Be right back.
> > > > > > > > > Thanks for you assistance so far.
> >
> > > > > > > > > On Dec 8, 11:58 am, "Ayende Rahien" <[EMAIL PROTECTED]>
> wrote:
> > > > > > > > > > Oh my, that was a slip.I meant, you are telling Rhino
> Mocks to
> > > > > > expect a
> > > > > > > > > call
> > > > > > > > > > with that particular parameters and to not consider
> anything
> > > > else
> > > > > > to
> > > > > > > > > match
> > > > > > > > > > this expectation
> >
> > > > > > > > > > On Sun, Dec 7, 2008 at 9:56 PM, Blair <
> > > > [EMAIL PROTECTED]>
> > > > > > > > > wrote:
> >
> > > > > > > > > > > Actually im using LLBLGen. I dont get what mean.
> >
> > > > > > > > > > > On Dec 8, 11:55 am, "Ayende Rahien" <[EMAIL PROTECTED]
> >
> > > > wrote:
> > > > > > > > > > > > That is because without the constraints, you are
> telling NH
> > > > > > that you
> > > > > > > > > want
> > > > > > > > > > > to
> > > > > > > > > > > > look for a call with that particular ID and that
> particual
> > > > feth
> > > > > > path
> >
> > > > > > > > > > > > On Sun, Dec 7, 2008 at 9:46 PM, Blair <
> > > > > > [EMAIL PROTECTED]>
> > > > > > > > > > > wrote:
> >
> > > > > > > > > > > > > Hi Guys,
> > > > > > > > > > > > > I am a huge fan of rhino mocks but
> I
> > > > have a
> > > > > > > > > question
> > > > > > > > > > > > > regarding constraints.
> >
> > > > > > > > > > > > > Below is a code snippit of setting an expectation
> > > > > > > > > > > > >
> Expect.Call(facilityService.FindByIdentity(id,
> > > > > > > > > > > > > prefetchPath))
> > > > > > > > > > > > > .Return(entity)
> > > > > > > > > > > > > .Constraints(Is.TypeOf(typeof(Guid)),
> > > > > > > > > Is.TypeOf(typeof
> > > > > > > > > > > > > (IPrefetchPath2)));
> >
> > > > > > > > > > > > > If I take the constraints out it doesnt work but
> when I
> > > > add
> > > > > > them
> > > > > > > > > > > > > everything is okay. the facilityService is create
> using
> > > > the
> > > > > > Strict
> > > > > > > > > > > > > mock call.
> >
> > > > > > > > > > > > > The ususual thing is on some unit tests I need to
> add
> > > > > > constraints
> > > > > > > > > like
> > > > > > > > > > > > > this and other times I don't so it is a little
> > > > inconsistent.
> >
> > > > > > > > > > > > > Can you explain why I need to do this and wether
> this is
> > > > a
> > > > > > problem
> > > > > > > > > > > > > with the tool or just me missing something and
> using it
> > > > > > > > > > > > > incorrectly. :)
> >
> > > > > > > > > > > > > Kind Regards,
> >
> > > > > > > > > > > > > Blair Davidson- Hide quoted text -
> >
> > > > > > > > > > > > - Show quoted text -- Hide quoted text -
> >
> > > > > > > > > > - Show quoted text -- Hide quoted text -
> >
> > > > > > > > - Show quoted text -- Hide quoted text -
> >
> > > > > > > - Show quoted text -- Hide quoted text -
> >
> > > > > - Show quoted text -- Hide quoted text -
> >
> > > - Show quoted text -
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---