public IEnumerator LEDTest()
    {
        // Use the Assert class to test conditions.
        SetupScene();
        yield return(new WaitForSecondsRealtime(1));

        GameObject testGnd   = new GameObject("testGnd");
        LogicNode  gndLogic  = testGnd.AddComponent <LogicNode>();
        GameObject testVcc   = new GameObject("testVcc");
        LogicNode  vccLogic  = testVcc.AddComponent <LogicNode>();
        GameObject LEDPrefab = Resources.Load <GameObject>("Prefabs/Lab/LEDChip");

        Assert.NotNull(LEDPrefab);
        GameObject newLED = GameObject.Instantiate <GameObject>(LEDPrefab);

        Assert.AreNotEqual(newLED, null);
        yield return(new WaitForSecondsRealtime(1));

        LEDScript  ledScript = newLED.GetComponent <LEDScript>();
        GameObject ledGnd = ledScript.GetLEDNodeGnd(); GameObject ledVcc = ledScript.GetLEDNodeVCC();

        Assert.AreNotEqual(ledGnd, null); Assert.AreNotEqual(ledVcc, null);
        testGnd.transform.position = ledGnd.transform.position; testVcc.transform.position = ledVcc.transform.position;
        yield return(new WaitForSecondsRealtime(1));

        ledScript.OnMouseUp();
        yield return(new WaitForSecondsRealtime(1));

        gndLogic.SetLogicState((int)LOGIC.INVALID); vccLogic.SetLogicState((int)LOGIC.INVALID);
        if (ledScript.isLEDON())
        {
            Assert.Fail();
        }

        gndLogic.SetLogicState((int)LOGIC.LOW); vccLogic.SetLogicState((int)LOGIC.HIGH);
        yield return(new WaitForSecondsRealtime(1));

        if (!ledScript.isLEDON())
        {
            Assert.Fail();
        }
        yield break;
    }
Beispiel #2
0
    IEnumerator FinishChecker()
    {
        for (int i = 0; i < MarksList.Count; i++)
        {
            Destroy(MarksList[i]);
        }
        MarksList.Clear();
        CheckerTagScript InputATag   = InputA.GetComponent <CheckerTagScript>();
        CheckerTagScript InputBTag   = InputB.GetComponent <CheckerTagScript>();
        CheckerTagScript InputCinTag = InputCin.GetComponent <CheckerTagScript>();
        CheckerTagScript OutputSTag  = OutputS.GetComponent <CheckerTagScript>();
        CheckerTagScript OutputCoTag = OutputCo.GetComponent <CheckerTagScript>();

        if (InputATag.GetCollidingObject() == null || InputBTag.GetCollidingObject() == null ||
            InputCinTag.GetCollidingObject() == null || OutputSTag.GetCollidingObject() == null ||
            OutputCoTag.GetCollidingObject() == null)
        {
            Debug.Log("All tags are not SNAPPED!");
            yield break;
        }
        Switch    InputASwitch   = InputATag.GetCollidingObject().GetComponent <Switch>();
        Switch    InputBSwitch   = InputBTag.GetCollidingObject().GetComponent <Switch>();
        Switch    InputCinSwitch = InputCinTag.GetCollidingObject().GetComponent <Switch>();
        LEDScript OutputSLED     = OutputSTag.GetCollidingObject().GetComponent <LEDScript>();
        LEDScript OutputCoLED    = OutputCoTag.GetCollidingObject().GetComponent <LEDScript>();



        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(false); InputCinSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputSLED.isLEDON() && OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(false); InputCinSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (!OutputSLED.isLEDON() && OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(true); InputCinSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (!OutputSLED.isLEDON() && OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(false); InputBSwitch.ToggleSwitch(true); InputCinSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputSLED.isLEDON() && !OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(false); InputCinSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (!OutputSLED.isLEDON() && OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(false); InputCinSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputSLED.isLEDON() && !OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(true); InputCinSwitch.ToggleSwitch(false);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (OutputSLED.isLEDON() && !OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        InputASwitch.ToggleSwitch(true); InputBSwitch.ToggleSwitch(true); InputCinSwitch.ToggleSwitch(true);
        logicManager.ResetAllLogic();
        yield return(new WaitForSecondsRealtime(1));

        if (!OutputSLED.isLEDON() && !OutputCoLED.isLEDON())
        {
            Debug.Log("Incorrect Output");
            if (Lab2Grade > 10)
            {
                Lab2Grade -= 5;
            }
            AddCheckMarkOrCross(false);
            yield break;
        }
        AddCheckMarkOrCross(true);

        DataInsert.inputLab2Grade += Lab2Grade;
        Debug.Log("Correct output!");
        yield return(new WaitForSecondsRealtime(5));

        SceneManager.LoadScene("Scenes/Postlab2");
    }