package com.seven.ikar.kotlin.core.model

import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertNotEquals
import org.junit.Test

class ClientMessageIdsTest {
    @Test
    fun localIdRoundTripsClientId() {
        val clientId = ClientMessageIds.newClientId()
        assertEquals(clientId, ClientMessageIds.clientIdFromLocalId(ClientMessageIds.localId(clientId)))
    }

    @Test
    fun generatedIdsAreUniqueAndNonLocalValuesAreRejected() {
        assertNotEquals(ClientMessageIds.newClientId(), ClientMessageIds.newClientId())
        assertNull(ClientMessageIds.clientIdFromLocalId("server-message-id"))
        assertNull(ClientMessageIds.clientIdFromLocalId(ClientMessageIds.LocalPrefix))
    }
}
