You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
728 B
24 lines
728 B
package net.aiterp.git.ykonsole2.infrastructure.testing
|
|
|
|
import net.aiterp.git.ykonsole2.domain.models.Program
|
|
import net.aiterp.git.ykonsole2.domain.models.ProgramRepository
|
|
|
|
class InMemoryProgramRepository : ProgramRepository {
|
|
private val programs = mutableListOf<Program>()
|
|
|
|
override fun findById(id: String): Program? = programs.firstOrNull { it.id == id }
|
|
|
|
override fun fetchAll(): List<Program> = programs.asSequence()
|
|
.map(Program::copy)
|
|
.sortedBy { it.name }
|
|
.toList()
|
|
|
|
override fun save(program: Program) {
|
|
programs.removeIf { it.id == program.id }
|
|
programs += program
|
|
}
|
|
|
|
override fun delete(program: Program) {
|
|
programs.removeIf { it.id == program.id }
|
|
}
|
|
}
|