Guest User

Untitled

a guest
Mar 11th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package myapp.module1.account
  2.  
  3. import org.scalatest.Spec
  4. import org.scalatest.matchers.ShouldMatchers
  5.  
  6. class AccountServiceSpec extends Spec with ShouldMatchers {
  7.  
  8. val accountSvc = new AccountServiceImpl()
  9.  
  10. it("should create a new account") {
  11. val username = "tiago"; val password = "secret"
  12. accountSvc.isUsernameInUse(username) should be (false)
  13. accountSvc.createAccount(new Account(username: username, password: password))
  14. accountSvc.isUsernameInUse(username) should be (true)
  15. }
  16.  
  17. it("should not create a new account with blank username") {
  18. intercept(RuntimeException) {
  19. accountSvc.createAccount(new Account(username: " ", password: "foo"))
  20. }
  21. }
  22.  
  23. it("should not create a new account with blank password") {
  24. intercept(RuntimeException) {
  25. accountSvc.createAccount(new Account(username: "foo", password: " "))
  26. }
  27. }
  28.  
  29. it("should not create a new account with blank username and password") {
  30. intercept(RuntimeException) {
  31. accountSvc.createAccount(new Account(username: " ", password: " "))
  32. }
  33. }
  34. }
Add Comment
Please, Sign In to add comment