And then there of course is your key phrase, "if the dog has been properly trained with the fence". Many are poorly trained with the fence and, IME, many are willing to run through it given a good enough reason. Just one more reason I dislike them.
Gotta say, I agree with everyone else that has said, "Get a physical fence." If you had one, OP, this would never have happened.
That is indeed the key phrase, and I should have emphasized it more. Of course, if a small dog teased at the fence when the confined dog was still in training, you bet an association could result! And I would agree some dogs certainly do learn to run through invisible fence. I have a friend with one of those. Two of her three (non Basenjis) never do it, one will with sufficient provocation. She knows she will get zapped, but she just runs fast and takes the punishment to get at those darn coyotes!
To the original point, I don't have a handy dog example, but my friend's stallions have not learned to dislike mares in heat because they get zapped trying to get at them. They know it is the fence and they know they are going to get a jolt, but a mare flashing right by the fence is sometimes just too much temptation! They don't go through the fence, however. Gallagher has a way of changing your mind. π
However, they have no issues breeding the same mares when the fence is not in the way, and show no difference in attitude toward them and other mares that have not been close to the fence, so I would say there is no confusion there in terms of the cause of the shock. Of course, horses may be smarter than the average dogβ¦..
In the city, I think an actual physical fence is pretty much a necessity. In the country, depending on circumstances, maybe not so much.