package de.arxsilex.maptools.converter.worker

import de.arxsilex.maptools.converter.core.ElevationOutputFormat
import java.nio.file.Files
import kotlin.io.path.createTempDirectory
import kotlin.test.Test
import kotlin.test.assertEquals

class ElevationRequestTest {
    @Test
    fun `parses multiple sources format and selection`() {
        val directory = createTempDirectory("elevation-request-")
        try {
            val first = Files.createFile(directory.resolve("first.asc"))
            val second = Files.createFile(directory.resolve("second.tif"))
            val request = ElevationRequest.parse(
                arrayOf(
                    "elevation",
                    "--input", first.toString(),
                    "--input", second.toString(),
                    "--output", directory.resolve("result.tif").toString(),
                    "--format", "GEOTIFF",
                    "--temp-dir", directory.resolve("temp").toString(),
                    "--areas", "r,7.0,49.0,8.0,50.0;c,49.5,7.5,2.0",
                ),
            )

            assertEquals(listOf(first, second), request.inputs)
            assertEquals(ElevationOutputFormat.GEOTIFF, request.outputFormat)
            assertEquals(2, request.areas.size)
        } finally {
            directory.toFile().deleteRecursively()
        }
    }
}
