I've got a 2012 MBA, less than 2 months old, that kept shutting down all by itself. Even if it was asleep when you woke it up, it would claim it was recovering from a restart.
Looking on various forums tried rebooting the laptop with the 'D' key this would then try the various boot tests and it would fail on the memory.
One genius appointment later and laptop was back a couple of days later having replaced the logic board and the fan. £330 Repair, all covered by warranty.
Not the best start for my Apple owing experience, but the Genius bar does help. Would have been repaired that day if they'd had the board in stock.