示例#1
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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
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);
        }
示例#5
0
        public void OutputEndpointConnectToSelf()
        {
            IOutputEndpoint point = new OutputEndpoint();

            point.ConnectTo(point);
        }