Is it professional for a professor to ask "surprise" questions on a test?
I don't see a reasonable answer beyond "it depends."  It depends on the question: some surprise questions are not actually so difficult and could reasonably be asked on a test with no special preparation, while others are very difficult indeed.  It also depends on the students: you can demand more of experienced and talented students than you can of typical beginners.

There's certainly no rule that says you can only ask test questions that are similar to previous questions the students have seen.  Sometimes asking unusual questions can be an excellent way to judge how well students have mastered the material.  At the same time, test questions that are too unfamiliar or difficult can be unproductive.  This is a balancing act that can be solved in many different ways, depending on the style of the person writing the test.