ANSWER:
If a person is not certain of Islam, this is an act of apostasy as Islam is a firm belief in the heart. Without it, one would not be a true Muslim.
This is different than when a person is a practicing Muslim but he gets these intrusive thoughts every now and then and yet he fights them and blocks them to the best of his ability.