package com.foxx.androidcast.diagnostics;

/*********************************************************************
 * CastMtuSamplerTest.java
 * Created at: Tue 19 May 2026 12:23:39 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class CastMtuSamplerTest
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 34 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	8261180ad608ac0071c4b5ecc15bb936ab228df873d37214d5e1c56d7110c95d
**********************************************************************/
import static org.junit.Assert.assertEquals;

import com.foxx.androidcast.CastConfig;

import org.junit.Test;

public class CastMtuSamplerTest {
    @Test
    public void calculate_wifiMtu1500() {
        CastMtuSampler.Info info = CastMtuSampler.calculate(1500, "wlan0");
        assertEquals(1500, info.linkMtu);
        assertEquals(CastConfig.UDP_CHUNK_SIZE, info.castDatagramBytes);
        assertEquals(CastConfig.UDP_CHUNK_SIZE - CastMtuSampler.ACUD_HEADER_BYTES,
                info.castFragPayloadBytes);
        assertEquals(CastConfig.UDP_CHUNK_SIZE + 28, info.ipv4WireBytes);
        assertEquals(1500 - info.ipv4WireBytes, info.headroomBytes);
    }

    @Test
    public void calculate_unknownLink_noHeadroom() {
        CastMtuSampler.Info info = CastMtuSampler.calculate(0, "");
        assertEquals(-1, info.headroomBytes);
        assertEquals(1228, info.ipv4WireBytes);
    }
}
