// Helper Methods:
 private static string ToHadesString(this Component component)
 {
     return(component switch
     {
         ANDGate and =>
         $"hades.models.gatter.And{and.NumberOfInputs} {and.Name} {and.Pos.X * 3}0 {and.Pos.Y * 3}0 @N 1001 1.0E-8",
         INVGate inv =>
         $"hades.models.gatter.Inv {inv.Name} {inv.Pos.X * 3}0 {inv.Pos.Y * 3}0 @N 1001 5.0E-9",
         NANDGate nand =>
         $"hades.models.gatter.Nand{nand.NumberOfInputs} {nand.Name} {nand.Pos.X * 3}0 {nand.Pos.Y * 3}0 @N 1001 1.0E-8",
         NORGate nor =>
         $"hades.models.gatter.Nor{nor.NumberOfInputs} {nor.Name} {nor.Pos.X * 3}0 {nor.Pos.Y * 3}0 @N 1001 1.0E-8",
         ORGate or =>
         $"hades.models.gatter.Or{or.NumberOfInputs} {or.Name} {or.Pos.X * 3}0 {or.Pos.Y * 3}0 @N 1001 1.0E-8",
         XNORGate xnor =>
         $"hades.models.gatter.Xnor{xnor.NumberOfInputs} {xnor.Name} {xnor.Pos.X * 3}0 {xnor.Pos.Y * 3}0 @N 1001 1.0E-8",
         XORGate xor =>
         $"hades.models.gatter.Xor{xor.NumberOfInputs} {xor.Name} {xor.Pos.X * 3}0 {xor.Pos.Y * 3}0 @N 1001 1.0E-8",
         InputPulse ip =>
         $"hades.models.io.PulseSwitch {ip.Name} {ip.Pos.X * 3}0 {ip.Pos.Y * 3}0 @N 1001 0.1 null",
         InputClock ic =>
         $"hades.models.io.ClockGen {ic.Name} {ic.Pos.X * 3}0 {ic.Pos.Y * 3}0 @N 1001 {InputClock.MsToSec()} 0.5 0.0",
         Input i => $"hades.models.io.Ipin {i.Name} {i.Pos.X * 3}0 {i.Pos.Y * 3}0 @N 1001  {i.IsActive}",
         Output o => $"hades.models.io.Opin {o.Name} {o.Pos.X * 3}0 {o.Pos.Y * 3}0 @N 1001 5.0E-9",
         _ => throw new ComponentNotFoundException(component.GetType().ToString())
     });
    public IEnumerator INVTest()
    {
        SetupScene();
        yield return(new WaitForSecondsRealtime(1));

        GameObject INVChip = Resources.Load <GameObject>("Prefabs/Lab/INVChip");

        Assert.NotNull(INVChip);
        GameObject InvGO     = GameObject.Instantiate <GameObject>(INVChip);
        INVGate    InvGate   = InvGO.GetComponent <INVGate>();
        string     device_id = INVGate.LOGIC_DEVICE_ID;

        yield return(new WaitForSecondsRealtime(1));

        Dictionary <string, GameObject> nandNodes = InvGate.GetLogicDictionary();
        List <GameObject> otherNodes = new List <GameObject>();

        for (int i = 0; i < 14; i++)
        {
            GameObject newNode = new GameObject("OtherNODE_" + i);
            otherNodes.Add(newNode);
        }
        List <LogicNode> otherLogic = new List <LogicNode>();

        for (int i = 0; i < 14; i++)
        {
            otherLogic.Add(otherNodes[i].AddComponent <LogicNode>());
        }
        List <GameObject> nandNodeList = new List <GameObject>();

        for (int i = 0; i < 14; i++)
        {
            GameObject DeviceNode;
            if (nandNodes.TryGetValue(device_id + i, out DeviceNode))
            {
                nandNodeList.Add(DeviceNode);
                otherNodes[i].transform.position = nandNodeList[i].transform.position;
            }
            else
            {
                Assert.Fail();
            }
        }
        yield return(new WaitForSecondsRealtime(1));

        Assert.IsTrue(!InvGate.IsDeviceOn());
        otherLogic[6].SetLogicState((int)LOGIC.LOW);
        otherLogic[13].SetLogicState((int)LOGIC.HIGH);
        yield return(new WaitForSecondsRealtime(1));

        Assert.IsTrue(!InvGate.IsDeviceOn());
        InvGate.SetSnapped(true);
        Assert.IsTrue(InvGate.IsDeviceOn());

        otherLogic[0].SetLogicState((int)LOGIC.LOW);
        otherLogic[2].SetLogicState((int)LOGIC.LOW);
        otherLogic[4].SetLogicState((int)LOGIC.LOW);
        otherLogic[8].SetLogicState((int)LOGIC.LOW);
        otherLogic[10].SetLogicState((int)LOGIC.LOW);
        otherLogic[12].SetLogicState((int)LOGIC.LOW);
        yield return(new WaitForSecondsRealtime(1));

        Assert.AreEqual((int)LOGIC.HIGH, nandNodeList[1].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.HIGH, nandNodeList[3].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.HIGH, nandNodeList[5].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.HIGH, nandNodeList[7].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.HIGH, nandNodeList[9].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.HIGH, nandNodeList[11].GetComponent <LogicNode>().GetLogicState());

        otherLogic[0].SetLogicState((int)LOGIC.HIGH);
        otherLogic[2].SetLogicState((int)LOGIC.HIGH);
        otherLogic[4].SetLogicState((int)LOGIC.HIGH);
        otherLogic[8].SetLogicState((int)LOGIC.HIGH);
        otherLogic[10].SetLogicState((int)LOGIC.HIGH);
        otherLogic[12].SetLogicState((int)LOGIC.HIGH);
        yield return(new WaitForSecondsRealtime(1));

        Assert.AreEqual((int)LOGIC.LOW, nandNodeList[1].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.LOW, nandNodeList[3].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.LOW, nandNodeList[5].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.LOW, nandNodeList[7].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.LOW, nandNodeList[9].GetComponent <LogicNode>().GetLogicState());
        Assert.AreEqual((int)LOGIC.LOW, nandNodeList[11].GetComponent <LogicNode>().GetLogicState());


        yield break;
    }