For testing queries in my repositories I write tests that actually hit a
real data source, SQL Server etc. I find its easier and more accurate then
trying to mock the underlying provider which I generally have no control
over. Its best to mock interfaces you control, like your repository.


On Fri, Jan 20, 2012 at 9:21 AM, Laksh <[email protected]> wrote:

> Well i was looking for actual example. I know what the test supposed
> to do. But i don’t know syntactically how do write the test using
> Rhino
>
> On Jan 20, 9:14 am, bill richards <[email protected]>
> wrote:
> > My take on this is as follows:
> >
> > You don't need to test the LINQ query. What you actually need to test
> > is the behaviour of the thing you are building. We can take it as read
> > that LINQ has been thoroughly tested by Microsoft and it does exactly
> > what it should do how it should do it.
> >
> > So then the question becomes .... what am I actually trying to test?
> >
> > Given that I have a thing for executing
> > When we invoke Execute passing in the id of a known registered package
> > Then Package should reference the registered Package
> >
> > Job done ... if the test passes, your LINQ query is correct if it
> > fails, it is wrong :o)
> >
> > On Jan 20, 5:01 am, Laksh <[email protected]> wrote:
> >
> >
> >
> > > I'm using 3.6 version of Rhino. How do i test the following funtion
> > > which has LINQ query
> >
> > > protected override void Execute(int PackageID)
> > >         {
> >
> > >             // get the package hierarchy from the database
> > >             IRepository<Package> repository =
> > > DefaultServiceLocator.Instance.GetInstance<IRepository<Package>>();
> > >             var package = repository.GetQuery()
> > >                 .Where(a => a.PackageID == PackageID)
> > >                 .Include(a => a.PackageDetails.Select(b =>
> > > b.DocumentTemplate))
> > >                 .Include(a => a.PackageArea)
> > >                 .Include(a => a.ReturnDetails)
> > >                 .FirstOrDefault();
> >
> > >                  this.Package.Set(package);
> > >         }- 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.
>
>

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