package com.foxx.androidcast.network.transport;

/*********************************************************************
 * StreamProtectionFactoryTest.java
 * Created at: Sun 17 May 2026 22:49:49 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class StreamProtectionFactoryTest
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (3 commits, 62 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	724ce23b0fe144918b7b2f3b0350cada92e61c011bd417e698143db1615d2fd2
**********************************************************************/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.foxx.androidcast.CastSettings;

import org.junit.Test;

public class StreamProtectionFactoryTest {
    @Test
    public void auto_defaultsToNone() {
        StreamProtectionEngine engine = StreamProtectionFactory.create(
                CastSettings.StreamProtection.AUTO, new TransportLossStats());
        assertEquals(StreamProtectionMode.NONE, engine.mode());
    }

    @Test
    public void none_mode() {
        StreamProtectionEngine engine = StreamProtectionFactory.create(
                CastSettings.StreamProtection.NONE, new TransportLossStats());
        assertEquals(StreamProtectionMode.NONE, engine.mode());
    }

    @Test
    public void fec34_mode() {
        StreamProtectionEngine engine = StreamProtectionFactory.create(
                CastSettings.StreamProtection.FEC_3_4, new TransportLossStats());
        assertEquals(StreamProtectionMode.FEC_3_4, engine.mode());
        assertTrue(engine instanceof CombinedProtectionEngine);
    }

    @Test
    public void fec34_withoutNack_isFecOnly() {
        StreamProtectionEngine engine = StreamProtectionFactory.create(
                CastSettings.StreamProtection.FEC_3_4, new TransportLossStats(), false);
        assertEquals(StreamProtectionMode.FEC_3_4, engine.mode());
        assertTrue(engine instanceof FecProtectionEngine);
    }

    @Test
    public void fecRs_withNack_isCombined() {
        StreamProtectionEngine engine = StreamProtectionFactory.create(
                CastSettings.StreamProtection.FEC_REED_SOLOMON, new TransportLossStats(), true);
        assertEquals(StreamProtectionMode.FEC_REED_SOLOMON, engine.mode());
        assertTrue(engine instanceof CombinedProtectionEngine);
    }

    @Test
    public void combinedEngine_hasFecAndNack() {
        StreamProtectionEngine engine = StreamProtectionFactory.create(
                CastSettings.StreamProtection.FEC_NACK, new TransportLossStats());
        assertTrue(engine instanceof CombinedProtectionEngine);
    }
}
