Created
January 7, 2020 07:07
-
-
Save adamw/16f5d1ca87da0b85a0363dfaebacefdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Example3Test extends AnyFlatSpec with Matchers { | |
import Example3._ | |
it should "add 1 point" in { | |
// given | |
val updatedPoints = new AtomicInteger(0) | |
val userId = UUID.randomUUID() | |
val stubDao = newStubDaoConstantPoints(15, updatedPoints) | |
// when | |
new Points(stubDao).increase(userId) | |
// then | |
updatedPoints.get() shouldBe 16 | |
} | |
it should "add 3 points" in { | |
// given | |
val updatedPoints = new AtomicInteger(0) | |
val userId = UUID.randomUUID() | |
val stubDao = newStubDaoConstantPoints(16, updatedPoints) | |
// when | |
new Points(stubDao).increase(userId) | |
// then | |
updatedPoints.get() shouldBe 19 | |
} | |
def newStubDaoConstantPoints(points: Int, | |
updatedPoints: AtomicInteger): Dao[Id] = new Dao[Id] { | |
override def currentPoints(userId: UUID): Id[Int] = points | |
override def updatePoints(userId: UUID, value: Int): Id[Unit] = | |
updatedPoints.set(value) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment