September 2018
Intermediate to advanced
398 pages
9h 43m
English
What about the cart? We would like to make sure that the cart is empty when the application is run so that we can add items to it.
Just like we did for the product, we will create a class named CartDaoSpec. The test looks as follows:
class CartDaoSpec extends PlaySpec with ScalaFutures with GuiceOneAppPerSuite { "CartDao" should { val app2dao = Application.instanceCache[CartDao] "be empty on database creation" in { val dao: CartDao = app2dao(app) dao.all().futureValue shouldBe empty } "accept to add new cart" in { val dao: CartDao = app2dao(app) val user = "userAdd" val expected = Set( Cart(user, "ALD1", 1), Cart(user, "BEO1", 5) ) val noise = Set( Cart("userNoise", "ALD2", 10) ) val allCarts = expected ++ noise val insertFutures ...Read now
Unlock full access