Exemplo n.º 1
0
        public void ChargeTheNeutralThenConnectInputOrNuetral()
        {
            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;
            };
            INeutralEndpoint neutralOut = new NeutralEndpoint();

            neutralOut.Produce(1);
            Assert.AreEqual(receivedSignal, 0);
            Assert.AreEqual(neutralReceivedSignal, 0);

            neutralOut.ConnectTo(input);
            Assert.AreEqual(receivedSignal, 1);
            Assert.AreEqual(neutralReceivedSignal, 0);

            neutralOut.ConnectTo(neutral);
            Assert.AreEqual(receivedSignal, 0);
            Assert.AreEqual(neutralReceivedSignal, 1);
        }
Exemplo n.º 2
0
        public void NeutralEndpointProduceToOutputWithNoResult()
        {
            IOutputEndpoint  output  = new OutputEndpoint();
            INeutralEndpoint neutral = new NeutralEndpoint(output);

            neutral.Produce(1);
        }
Exemplo n.º 3
0
        public void SendSignalBackAndForth()
        {
            INeutralEndpoint nuetral1        = new NeutralEndpoint();
            Int32            receivedSignal1 = 0;
            IEndpoint        senderPoint1    = null;

            nuetral1.Receive += (sdr, signal) =>
            {
                senderPoint1    = sdr;
                receivedSignal1 = signal;
            };

            INeutralEndpoint nuetral2        = new NeutralEndpoint();
            Int32            receivedSignal2 = 0;
            IEndpoint        senderPoint2    = null;

            nuetral2.Receive += (sdr, signal) =>
            {
                senderPoint2    = sdr;
                receivedSignal2 = signal;
            };

            Wire wire = new Wire(nuetral1, nuetral2);

            nuetral1.Produce(1);
            Assert.AreEqual(receivedSignal1, 0);
            Assert.AreEqual(receivedSignal2, 1);

            nuetral2.Produce(1);
            Assert.AreEqual(receivedSignal1, 1);
            Assert.AreEqual(receivedSignal2, 1);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public void NeutralEndpointProduceToInput()
        {
            IInputEndpoint input          = new InputEndpoint();
            Int32          receivedSignal = 0;

            input.Receive += (sender, signal) =>
            {
                receivedSignal = signal;
            };
            INeutralEndpoint neutral = new NeutralEndpoint(input);

            neutral.Produce(1);

            Assert.AreEqual(receivedSignal, 1);
        }
Exemplo n.º 6
0
        public void NeutralEndpointProduceToNeutral()
        {
            INeutralEndpoint neutral1       = new NeutralEndpoint();
            Int32            receivedSignal = 0;

            neutral1.Receive += (sender, signal) =>
            {
                receivedSignal = signal;
            };
            INeutralEndpoint neutral2 = new NeutralEndpoint(neutral1);

            neutral2.Produce(1);

            Assert.AreEqual(receivedSignal, 1);
        }
Exemplo n.º 7
0
        public void NeutralProduceInvalidSignal255()
        {
            INeutralEndpoint neutral = new NeutralEndpoint();

            neutral.Produce(255);
        }