/*
 * This file is part of the Owl Positioning System (OwlPS) project.
 * It is subject to the copyright notice and license terms in the
 * COPYRIGHT.t2t file found in the top-level directory of this
 * distribution and at
 *   https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
 * No part of the OwlPS Project, including this file, may be copied,
 * modified, propagated, or distributed except according to the terms
 * contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
 * distributed along with this file, either separately or by replacing
 * this notice by the COPYRIGHT.t2t file's contents.
 */

#include <cxxtest/TestSuite.h>

#include "wifidevice.hh"

class WifiDevice_test: public CxxTest::TestSuite
{
public:

  void test_constructors(void)
  {
    // Default constructor
    WifiDevice wifidevice1 ;
    WifiDevice wifidevice2("", "", WIFIDEVICE_DEFAULT_ANTENNA_GAIN,
                           WIFIDEVICE_DEFAULT_TRX_POWER) ;
    TS_ASSERT_EQUALS(wifidevice1, wifidevice2) ;

    // Copy constructor
    WifiDevice wifidevice3("192.168.0.1", "AA:BB:CC:DD:EE:FF", 5, 32) ;
    WifiDevice wifidevice4(wifidevice3) ;
    TS_ASSERT_EQUALS(wifidevice3, wifidevice4) ;
  }


  void test_accessors(void)
  {
    // Simple read accessors
    WifiDevice wifidevice1("192.168.0.1", "AA:BB:CC:DD:EE:FF", 6, 38) ;
    TS_ASSERT_EQUALS(wifidevice1.get_ip_addr(), "192.168.0.1") ;
    TS_ASSERT_EQUALS(wifidevice1.get_mac_addr(), "AA:BB:CC:DD:EE:FF") ;
    TS_ASSERT_EQUALS(wifidevice1.get_antenna_gain(), 6) ;
    TS_ASSERT_EQUALS(wifidevice1.get_trx_power(), 38) ;

    // Write & read accessors
    wifidevice1.set_ip_addr("10.0.8.42") ;
    TS_ASSERT_EQUALS(wifidevice1.get_ip_addr(), "10.0.8.42") ;
    wifidevice1.set_mac_addr("00:11:22:33:44:55") ;
    TS_ASSERT_EQUALS(wifidevice1.get_mac_addr(), "00:11:22:33:44:55") ;
    wifidevice1.set_antenna_gain(12.4) ;
    TS_ASSERT_DELTA(wifidevice1.get_antenna_gain(), 12.4, 0.00001) ;
    wifidevice1.set_trx_power(22.7) ;
    TS_ASSERT_DELTA(wifidevice1.get_trx_power(), 22.7, 0.00001) ;
  }


  void test_operators(void)
  {
    // ==
    WifiDevice wifidevice1("192.168.0.1", "AA:BB:CC:DD:EE:FF", 6, 38) ;
    WifiDevice wifidevice2("192.168.0.1", "AA:BB:CC:DD:EE:FF", 6, 38) ;
    TS_ASSERT_EQUALS(wifidevice1, wifidevice2) ;

    // !=
    WifiDevice wifidevice3("192.168.0.2", "AA:BB:CC:DD:EE:AA", 6, 38) ;
    TS_ASSERT(wifidevice2 != wifidevice3) ;

    // =
    wifidevice2 = wifidevice3 ;
    TS_ASSERT_EQUALS(wifidevice2, wifidevice3) ;
  }

} ;
