Mark objects as data objects in tests

This commit is contained in:
Michael Bull 2024-03-05 23:51:02 +00:00
parent d8ea6e1c04
commit 104f6a8ecd
4 changed files with 24 additions and 24 deletions

View File

@ -3,29 +3,29 @@ package com.github.michaelbull.result.example.model.domain
/**
* All possible things that can happen in the use-cases
*/
sealed class DomainMessage
sealed interface DomainMessage
/* validation errors */
object CustomerRequired : DomainMessage()
object CustomerIdMustBePositive : DomainMessage()
data object CustomerRequired : DomainMessage
data object CustomerIdMustBePositive : DomainMessage
object FirstNameRequired : DomainMessage()
object FirstNameTooLong : DomainMessage()
data object FirstNameRequired : DomainMessage
data object FirstNameTooLong : DomainMessage
object LastNameRequired : DomainMessage()
object LastNameTooLong : DomainMessage()
data object LastNameRequired : DomainMessage
data object LastNameTooLong : DomainMessage
object EmailRequired : DomainMessage()
object EmailTooLong : DomainMessage()
object EmailInvalid : DomainMessage()
data object EmailRequired : DomainMessage
data object EmailTooLong : DomainMessage
data object EmailInvalid : DomainMessage
/* exposed errors */
object CustomerNotFound : DomainMessage()
data object CustomerNotFound : DomainMessage
/* internal errors */
object SqlCustomerInvalid : DomainMessage()
object DatabaseTimeout : DomainMessage()
class DatabaseError(val reason: String?) : DomainMessage()
data object SqlCustomerInvalid : DomainMessage
data object DatabaseTimeout : DomainMessage
data class DatabaseError(val reason: String?) : DomainMessage

View File

@ -1,8 +1,8 @@
package com.github.michaelbull.result.example.model.domain
sealed class Event
sealed interface Event
object Created : Event()
class FirstNameChanged(val old: String, val new: String) : Event()
class LastNameChanged(val old: String, val new: String) : Event()
class EmailAddressChanged(val old: String, val new: String) : Event()
data object Created : Event
data class FirstNameChanged(val old: String, val new: String) : Event
data class LastNameChanged(val old: String, val new: String) : Event
data class EmailAddressChanged(val old: String, val new: String) : Event

View File

@ -18,8 +18,8 @@ import kotlin.test.assertTrue
class AsyncSuspendableBindingTest {
private sealed class BindingError {
object BindingErrorA : BindingError()
object BindingErrorB : BindingError()
data object BindingErrorA : BindingError()
data object BindingErrorB : BindingError()
}
@Test

View File

@ -148,9 +148,9 @@ class GetTest {
}
class Merge {
interface Direction
object Left : Direction
object Right : Direction
sealed interface Direction
data object Left : Direction
data object Right : Direction
@Test
fun returnsValueIfOk() {