package com.bytelyst.platform

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test

class BLPlatformConfigTest {

    @Test
    fun `should create config with required fields`() {
        val config = BLPlatformConfig(
            productId = "testapp",
            baseUrl = "https://api.test.com/api",
            applicationId = "com.test.app",
        )
        assertEquals("testapp", config.productId)
        assertEquals("https://api.test.com/api", config.baseUrl)
        assertEquals("com.test.app", config.applicationId)
    }

    @Test
    fun `should have sensible defaults`() {
        val config = BLPlatformConfig(
            productId = "testapp",
            baseUrl = "https://api.test.com",
            applicationId = "com.test.app",
        )
        assertEquals("android", config.platform)
        assertEquals("native", config.channel)
        assertEquals(15_000L, config.timeoutMs)
    }

    @Test
    fun `should allow overriding defaults`() {
        val config = BLPlatformConfig(
            productId = "testapp",
            baseUrl = "https://api.test.com",
            platform = "wear_os",
            channel = "keyboard",
            applicationId = "com.test.app",
            timeoutMs = 5_000L,
        )
        assertEquals("wear_os", config.platform)
        assertEquals("keyboard", config.channel)
        assertEquals(5_000L, config.timeoutMs)
    }

    @Test
    fun `data class equality should work`() {
        val a = BLPlatformConfig(productId = "x", baseUrl = "http://a", applicationId = "com.x")
        val b = BLPlatformConfig(productId = "x", baseUrl = "http://a", applicationId = "com.x")
        assertEquals(a, b)
        assertEquals(a.hashCode(), b.hashCode())
    }

    @Test
    fun `copy should create modified config`() {
        val original = BLPlatformConfig(productId = "x", baseUrl = "http://a", applicationId = "com.x")
        val modified = original.copy(productId = "y")
        assertEquals("y", modified.productId)
        assertEquals(original.baseUrl, modified.baseUrl)
    }
}
