In my experience it doesn't take into account castles or cities! I've fought some battles through auto-resolve that have led to my winning with very low casualties (given walls with defender fire, defender wall bonuses, narrow street fighting, etc) and with the enemy having men left at the end (not possible as they should run to the centre and rally, then fight to the death)! These men subsequently disappear as I capture the city\castle.

I don't for one second believe CA when they say auto-resolve takes everything into account - something funky's going on here with settlements.