package ballistics.orbitalPoints.timeStepper

import ballistics.types.EarthType
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.time.LocalDateTime
import java.time.ZoneOffset

internal class TLEStepperTest {
    @Test
    fun `calculate keeps TLE revolution at epoch`() {
        val stepper = TLEStepper(issTleFirst, issTleSecond, EarthType.PZ90d02)

        val point = stepper.calculate(stepper.baseEpoch)

        assertEquals(40945, point.vit)
    }

    @Test
    fun `calculate increments revolution at ascending node instead of elapsed period from epoch`() {
        val stepper = TLEStepper(issTleFirst, issTleSecond, EarthType.PZ90d02)

        val firstPass = stepper.calculate(LocalDateTime.of(2026, 6, 16, 14, 19, 50).toEpochSecond(ZoneOffset.UTC).toDouble())
        val secondPass = stepper.calculate(LocalDateTime.of(2026, 6, 16, 15, 56, 14).toEpochSecond(ZoneOffset.UTC).toDouble())

        assertEquals(firstPass.vit + 1, secondPass.vit)
    }

    private companion object {
        const val issTleFirst = "1 25994U 99068A   26167.13049375  .00000315  00000-0  73126-4 0  9997"
        const val issTleSecond = "2 25994  97.9457 216.7186 0001501 193.3628 244.8059 14.61102329409455"
    }
}
