public void SendSignal() { IInputEndpoint input = new InputEndpoint(); Int32 inputSignal = 0; input.Receive += (sender, signal) => { inputSignal = signal; }; IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(); INeutralEndpoint netrual = new NeutralEndpoint(); Int32 netrualSignal = 0; netrual.Receive += (sender, signal) => { netrualSignal = signal; }; Nexus nexus = new Nexus(6, input, output1, output2, netrual); output1.Produce(1); Assert.AreEqual(inputSignal, 1); Assert.AreEqual(netrualSignal, 1); output2.Produce(0); Assert.AreEqual(inputSignal, 1); Assert.AreEqual(netrualSignal, 1); output1.Produce(0); Assert.AreEqual(inputSignal, 0); Assert.AreEqual(netrualSignal, 0); netrual.Produce(1); Assert.AreEqual(inputSignal, 1); Assert.AreEqual(netrualSignal, 0); }
public void ContinuousSendSignals() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; input.Receive += (sender, signal) => { receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(input); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.Produce(0); Assert.AreEqual(receivedSignal, 0); output.Produce(0); Assert.AreEqual(receivedSignal, 0); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.Produce(0); Assert.AreEqual(receivedSignal, 0); }
public void ChargeTheOutputThenConnectInputOrNuetral() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; input.Receive += (sender, signal) => { receivedSignal = signal; }; INeutralEndpoint neutral = new NeutralEndpoint(); Int32 neutralReceivedSignal = 0; neutral.Receive += (sender, signal) => { neutralReceivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); Assert.AreEqual(receivedSignal, 0); Assert.AreEqual(neutralReceivedSignal, 0); output.ConnectTo(input); Assert.AreEqual(receivedSignal, 1); Assert.AreEqual(neutralReceivedSignal, 0); output.ConnectTo(neutral); Assert.AreEqual(receivedSignal, 0); Assert.AreEqual(neutralReceivedSignal, 1); }
public void OutputEndpointProduceToOutputWithNoResult() { IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(output1); output2.Produce(1); }
public void ChangeEndpointMidwayWithPrechargedSignal() { IInputEndpoint input1 = new InputEndpoint(); Int32 receivedSignal1 = 0; input1.Receive += (sender, signal) => { receivedSignal1 = signal; }; IInputEndpoint input2 = new InputEndpoint(); Int32 receivedSignal2 = 0; input2.Receive += (sender, signal) => { receivedSignal2 = signal; }; IOutputEndpoint output = new OutputEndpoint(input1); output.Produce(1); Assert.AreEqual(receivedSignal1, 1); Assert.AreEqual(receivedSignal2, 0); output.ConnectTo(input2); Assert.AreEqual(receivedSignal1, 0); Assert.AreEqual(receivedSignal2, 1); }
public void ToggleOneInpuSigalWhileOtherInputIs0() { IInputEndpoint input = new InputEndpoint(); Int32 inputSignal = 0; input.Receive += (sender, signal) => { inputSignal = signal; }; IOutputEndpoint output1 = new OutputEndpoint(); IOutputEndpoint output2 = new OutputEndpoint(); Nexus nexus = new Nexus(3, input, output1, output2); output1.Produce(1); Assert.AreEqual(inputSignal, 1); output1.Produce(0); Assert.AreEqual(inputSignal, 0); output1.Produce(1); Assert.AreEqual(inputSignal, 1); output1.Produce(0); Assert.AreEqual(inputSignal, 0); }
public void SendSignal() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; IEndpoint senderPoint = null; input.Receive += (sdr, signal) => { senderPoint = sdr; receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(); Wire wire = new Wire(input, output); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.Produce(0); Assert.AreEqual(receivedSignal, 0); }
public void OutputEndpointProduceToNeutral() { INeutralEndpoint neutral = new NeutralEndpoint(); Int32 receivedSignal = 0; neutral.Receive += (sender, signal) => { receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(neutral); output.Produce(1); Assert.AreEqual(receivedSignal, 1); }
public void DisconnectEndpointWithPrechargedSignal() { IInputEndpoint input = new InputEndpoint(); Int32 receivedSignal = 0; input.Receive += (sender, signal) => { receivedSignal = signal; }; IOutputEndpoint output = new OutputEndpoint(input); output.Produce(1); Assert.AreEqual(receivedSignal, 1); output.DisconnectEndpoint(); Assert.AreEqual(receivedSignal, 0); }
public void DisconnectInputWithConnectionPrecharged() { IInputEndpoint input = new InputEndpoint(); Int32 callTimes = 0; input.Receive += (sender, signal) => { callTimes++; }; IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); output.ConnectTo(input); input.DisconnectEndpoint(); Assert.AreEqual(callTimes, 2); }
public void ConnectPostCreating() { IInputEndpoint input1 = new InputEndpoint(); Int32 inputSignal1 = 0; input1.Receive += (sender, signal) => { inputSignal1 = signal; }; IInputEndpoint input2 = new InputEndpoint(); Int32 inputSignal2 = 0; input2.Receive += (sender, signal) => { inputSignal2 = signal; }; IOutputEndpoint output = new OutputEndpoint(); INeutralEndpoint netrual = new NeutralEndpoint(); Nexus nexus = new Nexus(6, input1, output, netrual); output.Produce(1); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 0); nexus.ConnectAt(input2, 3); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); }
public void ToggleInpuSigalWhilePrechargedBeforeCreating() { IInputEndpoint input1 = new InputEndpoint(); IInputEndpoint input2 = new InputEndpoint(); Int32 inputSignal1 = 0; input1.Receive += (sender, signal) => { inputSignal1 = signal; }; Int32 inputSignal2 = 0; input1.Receive += (sender, signal) => { inputSignal2 = signal; }; IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); Nexus nexus = new Nexus(3, output, input1, input2); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); output.Produce(0); Assert.AreEqual(inputSignal1, 0); Assert.AreEqual(inputSignal2, 0); output.Produce(0); Assert.AreEqual(inputSignal1, 0); Assert.AreEqual(inputSignal2, 0); output.Produce(1); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); output.Produce(1); Assert.AreEqual(inputSignal1, 1); Assert.AreEqual(inputSignal2, 1); output.Produce(0); Assert.AreEqual(inputSignal1, 0); Assert.AreEqual(inputSignal2, 0); }
public void OutputProduceInvalidSignal255() { IOutputEndpoint output = new OutputEndpoint(); output.Produce(255); }
public void UnconnectedOutputEndpointProduceWithoutException() { IOutputEndpoint output = new OutputEndpoint(); output.Produce(1); }