Guest User

Untitled

a guest
Dec 5th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. @RunWith(RobolectricTestRunner::class)
  2. @Config(application = TestDaggerTutoApplication::class)
  3. class MainActivityTest {
  4.  
  5. private lateinit var activity: MainActivity
  6.  
  7. @Before
  8. fun setUp(){
  9. activity = Robolectric.setupActivity(MainActivity::class.java)
  10. }
  11.  
  12. @Test
  13. @Throws(Exception::class)
  14. fun shouldShowProperDate() {
  15. val date = activity.findViewById(R.id.activity_main_date) as TextView
  16. assertEquals("Sat Oct 19 00:00:00 CET 1991", date.text)
  17. }
  18.  
  19. @Test
  20. @Throws(Exception::class)
  21. fun shouldStoreProperEmail() {
  22. val prefsUtils = activity.prefs
  23. prefsUtils.saveCurrentEmail("elvis@hotmail.com")
  24.  
  25. prefsUtils.saveCurrentEmail("test@hotmail.com")
  26. assertEquals("test@hotmail.com", prefsUtils.getCurrentEmail())
  27. }
  28. }
Add Comment
Please, Sign In to add comment