PJF16

Times example with mocking - 2

Jan 7th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. //works  
  2. @Test
  3.     public void itShouldSetAccountToLoggedInWhenPasswordMatches()
  4.     {
  5.         this.willPasswordMatch(true);
  6.         this.service.login("brett", "password");
  7.         verify(account, times(1)).setLoggedIn(true);
  8.     }
  9.  
  10. //works
  11.   @Test
  12.     public void itShouldSetAccountToLoggedInWhenPasswordMatches()
  13.     {
  14.         this.willPasswordMatch(true);
  15.         this.service.login("brett", "password");
  16.         verify(account).setLoggedIn(true);
  17.     }
  18.  
  19. //fail
  20.   @Test
  21.     public void itShouldSetAccountToLoggedInWhenPasswordMatches()
  22.     {
  23.         this.willPasswordMatch(true);
  24.         this.service.login("brett", "password");
  25.         verify(account, times(2)).setLoggedIn(true);
  26.     }
  27.  
  28. //fail
  29.  
  30.   @Test
  31.     public void itShouldSetAccountToLoggedInWhenPasswordMatches()
  32.     {
  33.         this.willPasswordMatch(true);
  34.         this.service.login("brett", "password");
  35.         verify(account, times(1)).setLoggedIn(false);
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment