public static void TestCase_ConnectDisconnectOfNot()
        {
            Circuit c   = new Circuit();
            NOT     not = new NOT();

            c.AddElement(not);
            Pin not_in  = not.GetPin(PinSide.INPUT, 0);
            Pin not_out = not.GetPin(PinSide.OUTPUT, 0);

            Require.That(not.GetNumberOfPins(PinSide.INPUT) == 1);
            Require.That(not.GetNumberOfPins(PinSide.OUTPUT) == 1);

            InTerminal x1 = new InTerminal();

            c.AddElement(x1);
            Pin x1_out = x1.GetPin(PinSide.OUTPUT, 0);

            c.Connect(x1_out, not_in);
            Require.That(not_in.ConnectedPin == x1_out);
            Require.That(x1_out.ConnectedPin == not_in);

            c.Disconnect(not_in);
            Require.That(x1_out.ConnectedPin == null);
            Require.That(not_in.ConnectedPin == null);

            c.RemoveElement(not);
            Console.WriteLine("TestCase_ConnectDisconnectOfNot passed.");
        }
        public static void TestCase_Fork_3Not_And_GatesSimulation()
        {
            void VerifyStates(Pin x1_out_pin, string x1_out_val,
                              Pin fork_in_pin, string fork_in_val,
                              Pin fork_out0_pin, string fork_out0_val,
                              Pin fork_out1_pin, string fork_out1_val,

                              Pin not0_in_pin, string not0_in_val,
                              Pin not1_in_pin, string not1_in_val,
                              Pin not0_out_pin, string not0_out_val,
                              Pin not1_out_pin, string not1_out_val,

                              Pin and_in0_pin, string and_in0_val,
                              Pin and_in1_pin, string and_in1_val,
                              Pin and_out_pin, string and_out_val,

                              Pin not2_in_pin, string not2_in_val,
                              Pin not2_out_pin, string not2_out_val,

                              Pin y1_in_pin, string y1_in_val,
                              Logic y1_res_real, string y1_res_exp)
            {
                Require.That(x1_out_pin.State.Value == Logic.StringToLogicValue(x1_out_val));

                Require.That(fork_in_pin.State.Value == Logic.StringToLogicValue(fork_in_val));
                Require.That(fork_out0_pin.State.Value == Logic.StringToLogicValue(fork_out0_val));
                Require.That(fork_out1_pin.State.Value == Logic.StringToLogicValue(fork_out1_val));

                Require.That(not0_in_pin.State.Value == Logic.StringToLogicValue(not0_in_val));
                Require.That(not1_in_pin.State.Value == Logic.StringToLogicValue(not1_in_val));
                Require.That(not0_out_pin.State.Value == Logic.StringToLogicValue(not0_out_val));
                Require.That(not1_out_pin.State.Value == Logic.StringToLogicValue(not1_out_val));

                Require.That(and_in0_pin.State.Value == Logic.StringToLogicValue(and_in0_val));
                Require.That(and_in1_pin.State.Value == Logic.StringToLogicValue(and_in1_val));
                Require.That(and_out_pin.State.Value == Logic.StringToLogicValue(and_out_val));

                Require.That(not2_in_pin.State.Value == Logic.StringToLogicValue(not2_in_val));
                Require.That(not2_out_pin.State.Value == Logic.StringToLogicValue(not2_out_val));

                Require.That(y1_in_pin.State.Value == Logic.StringToLogicValue(y1_in_val));
                Require.That(y1_res_real.Value == Logic.StringToLogicValue(y1_res_exp));
            }

            Circuit    cir = new Circuit();
            InTerminal x1  = new InTerminal();

            cir.AddElement(x1);

            FORK fork = new FORK();

            cir.AddElement(fork);

            AND and = new AND();

            cir.AddElement(and);

            NOT not0 = new NOT();

            cir.AddElement(not0);

            NOT not1 = new NOT();

            cir.AddElement(not1);

            NOT not2 = new NOT();

            cir.AddElement(not2);

            OutTerminal y1 = new OutTerminal();

            cir.AddElement(y1);

            Pin x1_out = x1.GetPin(PinSide.OUTPUT, 0);

            Pin fork_in   = fork.GetPin(PinSide.INPUT, 0);
            Pin fork_out0 = fork.GetPin(PinSide.OUTPUT, 0);
            Pin fork_out1 = fork.GetPin(PinSide.OUTPUT, 1);

            Pin not0_in  = not0.GetPin(PinSide.INPUT, 0);
            Pin not1_in  = not1.GetPin(PinSide.INPUT, 0);
            Pin not0_out = not0.GetPin(PinSide.OUTPUT, 0);
            Pin not1_out = not1.GetPin(PinSide.OUTPUT, 0);

            Pin and_in0 = and.GetPin(PinSide.INPUT, 0);
            Pin and_in1 = and.GetPin(PinSide.INPUT, 1);
            Pin and_out = and.GetPin(PinSide.OUTPUT, 0);

            Pin not2_in  = not2.GetPin(PinSide.INPUT, 0);
            Pin not2_out = not2.GetPin(PinSide.OUTPUT, 0);

            Pin y1_in = y1.GetPin(PinSide.INPUT, 0);

            cir.Connect(x1_out, fork_in);
            cir.Connect(fork_out0, not0_in);
            cir.Connect(fork_out1, not1_in);
            cir.Connect(not0_out, and_in0);
            cir.Connect(not1_out, and_in1);
            cir.Connect(and_out, not2_in);
            cir.Connect(not2_out, y1_in);

            x1.SimulationInputValue = new Logic(LogicValue.LOGIC_1);

            cir.RestartSimulation();
            VerifyStates(
                x1_out, "U", fork_in, "U", fork_out0, "U", fork_out1, "U",
                not0_in, "U", not0_out, "U", not1_in, "U", not1_out, "U",
                and_in0, "U", and_in1, "U", and_out, "U",
                not2_in, "U", not2_out, "U", y1_in, "U", y1.SimulationResult, "U");

            cir.NextMoment();
            VerifyStates(
                x1_out, "1", fork_in, "1", fork_out0, "U", fork_out1, "U",
                not0_in, "U", not0_out, "U", not1_in, "U", not1_out, "U",
                and_in0, "U", and_in1, "U", and_out, "U",
                not2_in, "U", not2_out, "U", y1_in, "U", y1.SimulationResult, "U");

            cir.NextMoment();
            VerifyStates(
                x1_out, "1", fork_in, "1", fork_out0, "1", fork_out1, "1",
                not0_in, "1", not0_out, "U", not1_in, "1", not1_out, "U",
                and_in0, "U", and_in1, "U", and_out, "U",
                not2_in, "U", not2_out, "U", y1_in, "U", y1.SimulationResult, "U");

            cir.NextMoment();
            VerifyStates(
                x1_out, "1", fork_in, "1", fork_out0, "1", fork_out1, "1",
                not0_in, "1", not0_out, "0", not1_in, "1", not1_out, "0",
                and_in0, "0", and_in1, "0", and_out, "U",
                not2_in, "U", not2_out, "U", y1_in, "U", y1.SimulationResult, "U");

            cir.NextMoment();
            VerifyStates(
                x1_out, "1", fork_in, "1", fork_out0, "1", fork_out1, "1",
                not0_in, "1", not0_out, "0", not1_in, "1", not1_out, "0",
                and_in0, "0", and_in1, "0", and_out, "0",
                not2_in, "0", not2_out, "U", y1_in, "U", y1.SimulationResult, "U");

            cir.NextMoment();
            VerifyStates(
                x1_out, "1", fork_in, "1", fork_out0, "1", fork_out1, "1",
                not0_in, "1", not0_out, "0", not1_in, "1", not1_out, "0",
                and_in0, "0", and_in1, "0", and_out, "0",
                not2_in, "0", not2_out, "1", y1_in, "1", y1.SimulationResult, "U");

            cir.NextMoment();
            VerifyStates(
                x1_out, "1", fork_in, "1", fork_out0, "1", fork_out1, "1",
                not0_in, "1", not0_out, "0", not1_in, "1", not1_out, "0",
                and_in0, "0", and_in1, "0", and_out, "0",
                not2_in, "0", not2_out, "1", y1_in, "1", y1.SimulationResult, "1");

            Console.WriteLine("TestCase_Fork_3Not_And_GatesSimulation passed.");
        }