Esempio n. 1
0
        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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public void OutputEndpointProduceToOutputWithNoResult()
        {
            IOutputEndpoint output1 = new OutputEndpoint();
            IOutputEndpoint output2 = new OutputEndpoint(output1);

            output2.Produce(1);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        public void OutputProduceInvalidSignal255()
        {
            IOutputEndpoint output = new OutputEndpoint();

            output.Produce(255);
        }
Esempio n. 14
0
        public void UnconnectedOutputEndpointProduceWithoutException()
        {
            IOutputEndpoint output = new OutputEndpoint();

            output.Produce(1);
        }