Beispiel #1
0
        public void SingleInputSingleOutput()
        {
            var board = new RelayBoard();

            var input  = new RelayInputMock("I");
            var output = new RelayOutputMock("O");

            board.Connect(input, output);
            board.Initialize();

            output.Check(false);

            input.Notify();
            output.Check(true);

            output.Reset();
            output.Check(false);

            input.Notify();
            output.Check(true);

            input.Notify();
            output.Check(true);

            output.Reset();
            output.Check(false);

            output.Reset();
            output.Check(false);

            board.Dispose();
        }
Beispiel #2
0
        public void ManyInputsSingleOutput()
        {
            const int nbInputs = 10;

            var board  = new RelayBoard();
            var output = new RelayOutputMock("O");

            var inputs = new RelayInputMock[nbInputs];

            for (var i = 0; i < nbInputs; i++)
            {
                inputs[i] = new RelayInputMock("I" + (i + 1));
                board.Connect(inputs[i], output);
            }

            board.Initialize();

            output.Check(false);

            for (var i = 0; i < inputs.Length; i++)
            {
                inputs[i].Notify();
                output.Check(true);

                output.Reset();
                output.Check(false);
            }

            for (var i = 0; i < inputs.Length; i++)
            {
                inputs[i].Notify();
            }
            output.Check(true);

            output.Reset();
            output.Check(false);

            for (var i = 0; i < inputs.Length; i++)
            {
                inputs[i].Notify();
                output.Check(true);

                output.Reset();
                output.Check(false);
            }
        }
Beispiel #3
0
        public void UnsubcribeCallbackManyInputSingleOutput()
        {
            var board = new RelayBoard();

            var i1 = new RelayInputMock("I1");
            var i2 = new RelayInputMock("I2");
            var o1 = new RelayOutputMock("O1");

            var c1 = board.Connect(i1, o1)
                     .Subscribe(p => { });
            var c2 = board.Connect(i2, o1)
                     .Subscribe(p => { });

            board.Initialize();

            o1.Check(false);

            i1.Notify();
            o1.Check(true);

            o1.Reset();
            o1.Check(false);

            i2.Notify();
            o1.Check(true);

            o1.Reset();
            o1.Check(false);

            c2.Dispose();

            i1.Notify();
            o1.Check(true);

            o1.Reset();
            o1.Check(false);

            i2.Notify();
            o1.Check(true);

            board.Dispose();
        }
Beispiel #4
0
        public void UnsubcribeConnectorSingleInputManyOutput()
        {
            var board = new RelayBoard();

            var i1 = new RelayInputMock("I1");
            var o1 = new RelayOutputMock("O1");
            var o2 = new RelayOutputMock("O2");

            var c1 = board.Connect(i1, o1);

            c1.Subscribe(p => { });
            var c2 = board.Connect(i1, o2);

            c2.Subscribe(p => { });

            board.Initialize();
            Console.WriteLine(board.Report());

            o1.Check(false);
            o2.Check(false);

            i1.Notify();
            o1.Check(true);
            o2.Check(true);

            o1.Reset();
            o2.Reset();
            o1.Check(false);
            o2.Check(false);

            c2.Dispose();
            Console.WriteLine(board.Report());

            i1.Notify();
            o1.Check(true);
            o2.Check(false);

            board.Dispose();
        }
Beispiel #5
0
 public static void CheckAndReset(this RelayOutputMock output, bool isFlaged)
 {
     output.Check(isFlaged);
     output.Reset();
 }