Created
May 31, 2019 04:33
-
-
Save Kalimaha/e6ae6e0b06722b59a48829ac279bf902 to your computer and use it in GitHub Desktop.
Transaction model
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
| package blog.guidobarbaglia.models | |
| import java.time.LocalDateTime | |
| data class Transaction(val creditCardNumber: String, val amount: Double, val timestamp: LocalDateTime) |
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
| 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