コード例 #1
0
    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;
    }