The components of chocolate that are toxic to dogs are caffeine and theobromine. It's true that a dog can tolerate some amount of these chemicals without experiencing symptoms at all, and how muchwhether a food is safe"safe" is largely dependent on the dog's size and how much caffeine and theobromine was consumedit contains, which can be determined by taking into account both volume and what exactly was eatenit is, as items made with chocolate have varying amounts of actual chocolate. There are even online calculators available to help people determine whether the dog will likely experience symptoms based on these factors.
However, that said, obviously it's better to not give the dog chocolate cake at all. Besides the concern of actual poisoning, cake is obviously a "junk food" for dogs as well as humans, as it's loaded with sugar and fat. Cake also probably contains milk with lactose, which dogs typically cannot digest either. So even if the dog does not get poisoned from the chocolate, the dog could still experience symptoms like vomiting or diarrhea, which are also symptoms of theobromine poisoning. They could end up having to rush the dog to the vet because it would be impossible to tell if it's lactose intolerance or poisoning.