public void TestNAndGateNoOutput() { List<SimulatedComponent> components = new List<SimulatedComponent>(); NAndGate ag = new NAndGate(); Connector inputConnectorA = new Connector(); ag.ConnectInputA(inputConnectorA); Connector inputConnectorB = new Connector(); ag.ConnectInputB(inputConnectorB); components.Add(ag); bool currSignal1 = false; bool currSignal2 = false; for (int x = 1; x < 30; x++) { inputConnectorA.SendSignal(currSignal1); inputConnectorB.SendSignal(currSignal2); foreach (SimulatedComponent sc in components) { sc.Tick(); } Console.WriteLine("Signal1[" + currSignal1.ToString() + "] Signal2[" + currSignal2.ToString() + "]"); currSignal1 = !currSignal1; if (currSignal1 == false) { currSignal2 = !currSignal2; } } }
public void TestNAndGateAllConnectorsGood() { List<SimulatedComponent> components = new List<SimulatedComponent>(); NAndGate ag = new NAndGate(); Connector inputConnectorA = new Connector(); ag.ConnectInputA(inputConnectorA); Connector inputConnectorB = new Connector(); ag.ConnectInputB(inputConnectorB); Connector outputConnector = new Connector(); ag.ConnectOutput(outputConnector); components.Add(ag); bool currSignal1 = false; bool currSignal2 = false; for (int x = 1; x < 30; x++) { inputConnectorA.SendSignal(currSignal1); inputConnectorB.SendSignal(currSignal2); foreach (SimulatedComponent sc in components) { sc.Tick(); } Console.WriteLine("Signal1[" + currSignal1.ToString() + "] Signal2[" + currSignal2.ToString() + "] = Result[" + outputConnector.HasSignal().ToString() + "]"); Assert.IsTrue(outputConnector.HasSignal() == (! (currSignal1 && currSignal2))); currSignal1 = !currSignal1; if (currSignal1 == false) { currSignal2 = !currSignal2; } } }