I find the (mostly) legendary character of Diogenes very interesting! Perhaps even an example for our times - as a man who was absolutely outside of the System of his era; utterly lacking in wealth, power, status; yet who indirectly - almost paradoxically, and perhaps by spiritual rather than material means - provided a commentary and correction of the hypocritical, self-seeking, hedonic values of 'normal people' and those in authority.
What I see at work in Diogenes' life and antics, is a man who repeatedly tests sincerity - both his own and that of those he encounters - by deliberate acts of self-sabotage.
By living in poverty and squalor, and performing disruptive, provocative, and bestial acts deliberately (so ensure he remains untouchable, out-cast); Diogenes renders himself disgusting; and those who reject him for this reason are revealed as hypocrites...
...Whose affectations of virtue are so superficial as to be undermined by disgust ...Who are really seeking a comfortable life, rather than Goodness... Who reject truth and virtue when they come in an ungracious form.
Diogenes eschews comfort and safety, and places himself voluntarily at the lowest and most despicable level of his society - as guarantees of his sincerity; yet something about him nonetheless leads to a reputation for wisdom - and therefore the temptation to 'use' his celebrity to attain power, influence, comfort...
Therefore, when Alexander the Great approached and offered him anything; Diogenes responded brusquely, demanding the Emperor move aside, and stop blocking the sunlight!
The casualness of rejection was Diogenes rejecting the temptations of riches and prestige.
The calculated rudeness to the most powerful man in the world, was partly Diogenes overcoming the test of fear in the presence of a man with life and death power; but was also intended to test Alexander - to educate the Emperor.
If Alexander was offended or angered, he would reveal that his appreciation of the wisdom and example of Diogenes was a superficial affectation, self-interested, and approval-seeking.
By reacting negatively to Diogenes' rudeness; Alexander would show (himself and others) that in approaching Diogenes he was seeking the endorsement of this dirty hermit.
Therefore, Alexander was being challenged to see past rudeness and disrespect, and find the wisdom within.
By quietly complying with Diogenes wish for him to stand aside and cease casting a shadow on the philosopher; Alexander showed that he had understood the lesson - and thereby passed the test.