It will be obvious when the Mahdi comes because he will be accompanied by cosmic signs that will make clear that it is him (for instance, a call from the heavens, the arrival of Jesus with him). His arrival will also be apparent for all people and not confined to one group or region. (You can read more about the signs on this website.)
This is apart from the signs that all the Imams bore, such as comprehensive knowledge, knowledge of all languages, knowledge of all aspects of the religion, the ability to perform karamat, etc. Failing one of these things (for instance, not being able to understand a certain language or answer a question accurately) means he is not the Mahdi.
Anyone who does not have these signs is not the Mahdi.
In my understanding of the texts, when the Mahdi arrives, the question will not be whether he is the Mahdi or is a fake. It will be obvious that he is someone different from everyone else with a global role. The question will be whether people choose to follow him or not, as some people will not like what he stands for.