Are there any things to avoid when being given a free bike? Someone has just given me a free mountain bike (No obvious branding on it, but its got a 21-speed Shimano gear system and a shock absorber between the front and back of the bike in the middle of the chassis). It's been sitting in a shed, un-touched for about 2-3 years.

It's clearly in need of a service (lubricating, replacing the brake cables as their ends are frayed). But is there anything in particular that I should look for which would indicate that it's not worth repairing and that I should give it to someone else for parts?
It's probably worth riding, if you don't have another bike.

First, of course, simply wipe off the dust (or hose it down and wipe dry).  Then examine for bad rust.  If it's an inexpensive bike that was stored where it wasn't completely dry there's apt to be some rust spots here and there, which is OK.  But gobs of rust around the bearings is a bad sign.  If the chain is badly rusted that's not fatal, but not a great sign.

Air up the tires.  (Once you decide you'll be a bike rider you'll want to get a bike pump of the full-sized "floor" variety.)  Then pick up the bike and spin each tire -- they should spin freely, with no gritty feel in the bearings.  Note that the brakes may drag, but that's not a serious problem.

Pick up the rear wheel (or hang the whole thing from ropes or some such) and then turn the pedals with your hand.  The chain will likely clatter quite a bit, but by adjusting the shifters (and maybe "helping" the chain with your hand a bit) you should be able to get squarely onto gears front and rear and then turn the crank at a fair pace.  There may still be clatter, but you shouldn't feel a gritty feeling in the bearings of the crank.  (Note that if the chain is badly rusted with "frozen links" you won't be able to get beyond this point.)

Next, try the brakes.  If the bike has been exposed to the weather the brake cables are apt to be badly rusted, but that not a big ticket item.  But for a test ride you want at least one working brake.

If you get this far, try to adjust the seat to about your height (this may require an Allen wrench of the appropriate metric size, or a regular adjustable wrench for a bolt head).  (Keep in mind that if anything on the bike is rusted it's apt to be the seat height adjustment, though.)  

But if you can get the seat semi-adjusted, get on the bike and try riding a short distance.  If you're brave you can try the shifters, but you're more feeling for a grinding feeling anywhere, in the pedals, wheels, or steering.  And somewhere along the way examine the condition of the tires, looking in particular for cracks in the sidewalls.

At this point you may have no problems at all with the bike, in which case you can just ride it, though you should probably take it to a shop to be tuned up within a few weeks (or buy a good book on the topic and do it yourself).

Or you may have found something (rusted brake cables, bad shifting, rotten tires, etc) that isn't "fatal" but demands more immediate service.  Almost certainly worth paying a shop to fix.

Or you may have found crunchy bearings, severe overall rust, or some other problem that makes the bike at best a "fixer upper".  Only spend money on this one if you've got a "thing" for "lonely" machines.

One thing to note:  If you decide, for whatever reason, that the bike is not for you, ask around for an organization that "recycles" them.  In our area Christmas Anonymous and the Kiwanis Club will take bikes in any condition to be rehabbed for kids and needy adults.  Bikes that are in too bad of shape to be rehabbed are stripped for spare parts and the rest is recycled.