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 inputConnectToTheSameOutputMoreThanOneTime() { IInputEndpoint input = new InputEndpoint(); Int32 callTimes = 0; input.Receive += (sender, signal) => { callTimes++; }; IOutputEndpoint output = new OutputEndpoint(); input.ConnectTo(output); Assert.AreEqual(callTimes, 1); input.ConnectTo(output); Assert.AreEqual(callTimes, 1); output.ConnectTo(input); Assert.AreEqual(callTimes, 1); output.ConnectTo(input); Assert.AreEqual(callTimes, 1); input.ConnectTo(output); Assert.AreEqual(callTimes, 1); output.ConnectTo(input); Assert.AreEqual(callTimes, 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 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 OutputEndpointConnectToSelf() { IOutputEndpoint point = new OutputEndpoint(); point.ConnectTo(point); }