Skip to content

Instantly share code, notes, and snippets.

@Kalimaha
Created May 31, 2019 04:33
Show Gist options
  • Select an option

  • Save Kalimaha/e6ae6e0b06722b59a48829ac279bf902 to your computer and use it in GitHub Desktop.

Select an option

Save Kalimaha/e6ae6e0b06722b59a48829ac279bf902 to your computer and use it in GitHub Desktop.
Transaction model
package blog.guidobarbaglia.models
import java.time.LocalDateTime
data class Transaction(val creditCardNumber: String, val amount: Double, val timestamp: LocalDateTime)
package blog.guidobarbaglia.models
import org.junit.BeforeClass
import org.junit.Test
import java.time.LocalDateTime
import kotlin.test.assertEquals
class TransactionTest {
companion object {
@JvmStatic
private lateinit var transaction: Transaction
private const val creditCardNumber: String = "123123123"
private const val amount: Double = 12.34
private val timestamp: LocalDateTime = LocalDateTime.now()
@BeforeClass
@JvmStatic
fun initialize() {
transaction = Transaction(creditCardNumber = creditCardNumber, amount = amount, timestamp = timestamp)
}
}
@Test
fun `It sets the hashed credit card number`() {
assertEquals(creditCardNumber, transaction.creditCardNumber)
}
@Test
fun `It sets the amount of the transaction`() {
assertEquals(amount, transaction.amount)
}
@Test
fun `It sets the timestamp of the transaction`() {
assertEquals(timestamp, transaction.timestamp)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment