I remember back in English class (ages and ages ago), I was taught that you should always say 'could not' unless it's in dialogue. I wanted to know, should I actually avoid these shortenings? Everytime I write 'could not' or 'would not', I feel like it reads a little odd.
I'd be quite happy writing "He couldn't decide whether or not to eat his greens". If you write it as "He could not decide..." it seems to gain an emphasis on NOT that just doesn't apply - or maybe it does, and you want to make that emphasis. Similar difference between 1/ "I'd be happy if only you'd stop asking stupid questions." and 2/ "I would be happy if only you'd stop asking stupid questions." 1/ sounds like a request. 2/ sounds like a statement of all that I require for happiness. Rule No. 1 of writing...write what sounds like what you want it to mean.
The 'no contractions' rule applies to formal writing. Most contemporary novels don't use a formal voice for the narration, so you wouldn't need to follow the rule. If you're trying to write in a formal style, you should remember the rule, though.
Not necessarily just dialogue, but in narrative where we're in the character's head. She wanted me to just leave? I couldn't do it. Also, sometimes a character might use it in dialogue, for emphasis -- "You wanted me to just leave? I'm sorry, but I could not do that!" As BayView said, yes in formal writing, generally you wouldn't use a contraction.
In my head it depends on the sentence. Sometimes 'could not' belongs in the sentence cadence. Rarely that's also true for dialogue and internal monologue. Because I hate rules that I don't find a good rationale for (don't use contractions in formal writing) I looked at a couple Google hit opinions. http://grammar.yourdictionary.com/style-and-usage/using-contractions.html That makes more sense than choosing something purely because it is a rule. From Grammar Girl: