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 inputConnectToTheSameNeutralMoreThanOneTime() { IInputEndpoint input = new InputEndpoint(); Int32 callTimes = 0; input.Receive += (sender, signal) => { callTimes++; }; INeutralEndpoint neutral = new NeutralEndpoint(); input.ConnectTo(neutral); Assert.AreEqual(callTimes, 1); input.ConnectTo(neutral); Assert.AreEqual(callTimes, 1); neutral.ConnectTo(input); Assert.AreEqual(callTimes, 1); neutral.ConnectTo(input); Assert.AreEqual(callTimes, 1); input.ConnectTo(neutral); Assert.AreEqual(callTimes, 1); neutral.ConnectTo(input); Assert.AreEqual(callTimes, 1); }
public void Oscillate20HzOnTime() { IInputEndpoint input = new InputEndpoint(); input.ConnectTo(_oscillator10Hz.Output); input.Receive += (sd, sgn) => { Thread.Sleep(1); if ((Int32)_count >= 5) { _startPower.Off(); } else { _count = (Int32)_count + 1; } }; ThreadHelper.ExecuteThenSleepShortly(() => _startPower.On(), 300); Assert.AreEqual(_count, 5); _count = 0; ThreadHelper.ExecuteThenSleepShortly(() => _startPower.On(), 250); Assert.AreEqual(_count, 5); _count = 0; ThreadHelper.ExecuteThenSleepShortly(() => _startPower.On(), 100); Assert.IsTrue((Int32)_count < 5); }
public void OscillateFloppyExactly() { IInputEndpoint input = new InputEndpoint(); IList <Int32> results = new List <Int32>(); input.ConnectTo(_oscillator10Hz.Output); input.Receive += (sd, sgn) => { Thread.Sleep(1); if ((Int32)_count >= 5) { _startPower.Off(); } else { _count = (Int32)_count + 1; results.Add(sgn); } }; ThreadHelper.ExecuteThenSleepShortly(() => _startPower.On(), 500); Assert.AreEqual(results.Count, 5); Assert.AreEqual(results[0], 0); Assert.AreEqual(results[1], 1); Assert.AreEqual(results[2], 0); Assert.AreEqual(results[3], 1); Assert.AreEqual(results[4], 0); }
public void Reconnect() { IInputEndpoint input1 = new InputEndpoint(); IInputEndpoint input2 = new InputEndpoint(input1); input1.DisconnectEndpoint(); input1.ConnectTo(input2); Assert.IsNotNull(input1.ConnectedPoint); Assert.IsNotNull(input2.ConnectedPoint); Assert.AreSame(input1.ConnectedPoint, input2); Assert.AreSame(input2.ConnectedPoint, input1); }
public void AbleToOscillate() { IInputEndpoint input = new InputEndpoint(); input.ConnectTo(_oscillator10Hz.Output); input.Receive += (sd, sgn) => { Thread.Sleep(1); _count = (Int32)_count + 1; }; ThreadHelper.ExecuteThenSleepShortly(() => _startPower.On(), 500); _startPower.Off(); Assert.IsTrue((Int32)_count > 0); }
public void Oscillate25HzOnTime() { IOscillator oscillator = new Oscillator(20); PowerSupplier power = new PowerSupplier(); power.Output.ConnectTo(oscillator.Start); _count = 0; Boolean oscillating = false; IInputEndpoint input = new InputEndpoint(); input.ConnectTo(oscillator.Output); input.Receive += (sd, sgn) => { Thread.Sleep(1); if ((Int32)_count >= 5) { _startPower.Off(); } else { _count = (Int32)_count + 1; } }; ThreadHelper.ExecuteThenSleepShortly(() => power.On(), 200); Assert.AreEqual(_count, 5); _count = 0; ThreadHelper.ExecuteThenSleepShortly(() => power.On(), 100); Assert.AreEqual(_count, 5); _count = 0; ThreadHelper.ExecuteThenSleepShortly(() => power.On(), 40); Assert.IsTrue((Int32)_count < 5); }
public void InputEndpointConnectToSelf() { IInputEndpoint point = new InputEndpoint(); point.ConnectTo(point); }