Accurate pregnancy test?¿

After having unprotected sex how soon can you take a pregnancy test and it be accurate?