package tmcsim.cadsimulator.viewer.model;

import java.util.logging.Level;
import java.util.logging.Logger;
import static junit.framework.Assert.assertEquals;
import junit.framework.TestCase;
import tmcsim.common.CADEnums;

/**
 *
 * @author jdalbey
 */
public class CADSimulatorStatusTest extends TestCase
{

    CADSimulatorStatus stat;

    public CADSimulatorStatusTest(String testName)
    {
        super(testName);
    }

    public void setUp()
    {
        stat = new CADSimulatorStatus();
    }

    /**
     * Test of connectClient method, of class CADSimulatorStatus.
     */
    public void testConnectClient()
    {
        System.out.println("connectClient");
        stat.connectClient();
        assertEquals(1, stat.getNumClients());
    }

    /**
     * Test of disconnectClient method, of class CADSimulatorStatus.
     */
    public void testDisconnectClient()
    {
        System.out.println("disconnectClient");
        stat.connectClient();
        stat.connectClient();
        stat.disconnectClient();
        assertEquals(1, stat.getNumClients());
    }

    /**
     * Test of getNumClients method, of class CADSimulatorStatus.
     */
    public void testGetNumClients()
    {
        System.out.println("getNumClients");
        int expResult = 0;
        int result = stat.getNumClients();
        assertEquals(expResult, result);
    }

    /**
     * Test of setSimManagerStatus method, of class CADSimulatorStatus.
     */
    public void testSetSimManagerStatus()
    {
        System.out.println("setSimManagerStatus");
        stat.setSimManagerStatus(false);
        assertFalse(stat.isSimManagerConnected());
    }

    /**
     * Test of setTime method, of class CADSimulatorStatus.
     */
    public void testSetTime()
    {
        System.out.println("setTime");
        long seconds = 1L;
        stat.setTime(seconds);
        String result = stat.getCurrentTime();
        assertEquals("0:00:01", result);
    }

    /**
     * Test of setScriptStatus method, of class CADSimulatorStatus.
     */
    public void testSetScriptStatus()
    {
        System.out.println("setScriptStatus");
        CADEnums.SCRIPT_STATUS newStatus = CADEnums.SCRIPT_STATUS.NO_SCRIPT;
        stat.setScriptStatus(newStatus);
        CADEnums.SCRIPT_STATUS expResult = CADEnums.SCRIPT_STATUS.NO_SCRIPT;
        CADEnums.SCRIPT_STATUS result = stat.getScriptStatus();
        assertEquals(expResult, result);
        newStatus = CADEnums.SCRIPT_STATUS.ATMS_SYNCHRONIZATION;
        stat.setScriptStatus(newStatus);
        assertEquals(CADEnums.SCRIPT_STATUS.ATMS_SYNCHRONIZATION, stat.getScriptStatus());
        newStatus = CADEnums.SCRIPT_STATUS.SCRIPT_PAUSED_STARTED;
        stat.setScriptStatus(newStatus);
        assertEquals(CADEnums.SCRIPT_STATUS.SCRIPT_PAUSED_STARTED, stat.getScriptStatus());
    }

    public void testInfoMsg()
    {
        Logger cadSimLogger = Logger.getLogger("tmcsim.cadsimulator");
        cadSimLogger.logp(Level.INFO, "", "", "Sample Info Message.");
        assertEquals(". = Sample Info Message.", stat.getInfoMessages());
    }
}
