#include "wifi_profile_selection.h"
#include <cassert>

int main() {
    // Primary absent -> secondary succeeds; DHCP renewals never switch back.
    WifiProfileSelection fallback(true);
    assert(fallback.current() == 0);
    assert(fallback.disconnected() == 1);
    fallback.got_ip();
    fallback.got_ip();
    assert(fallback.current() == 1);
    // A temporary drop retries the working secondary, and successful reconnect
    // restores that one retry for the next outage.
    assert(fallback.disconnected() == 1);
    fallback.got_ip();
    assert(fallback.disconnected() == 1);
    assert(fallback.disconnected() == 0);
    // Neither network reachable: keep trying both, with no terminal failure.
    for (unsigned i = 0; i < 10; ++i)
        assert(fallback.disconnected() == ((i + 1) % 2));

    // Hotspot A/B: working primary is retried once when turned off, then Wi-Fi.
    WifiProfileSelection hotspot(true);
    hotspot.got_ip();
    assert(hotspot.disconnected() == 0);
    assert(hotspot.disconnected() == 1);
    hotspot.got_ip();
    assert(hotspot.current() == 1);

    WifiProfileSelection single(false);
    for (unsigned i = 0; i < 10; ++i) assert(single.disconnected() == 0);
    single.got_ip();
    assert(single.disconnected() == 0);
    assert(single.disconnected() == 0);
}
