Exemplo n.º 1
0
        public void Output_is_in_same_context_as_input()
        {
            var sut = new Execute_task();

            var msg = new Message("a/b/x.in", "hello");
            var task = new Task(msg,
                                new Operation("x", (input, outputCont, _) => {
                                                                          		outputCont(new Message("x.out", input.Data.ToString() + "x"));
                                                                          }));
            var results = new List<IMessage>();
            sut.Result += _ => results.Add(_);

            sut.Process(task);
            Assert.AreEqual("hellox", results[0].Data.ToString());
            Assert.AreEqual("a/b/x.out", results[0].Port.Fullname);
        }
Exemplo n.º 2
0
        public void Operation_with_single_output()
        {
            var sut = new Execute_task();

            var msg = new Message("x.in", "hello");
            var task = new Task(msg,
                                new Operation("x", (input, outputCont, _) => {
                                                                          		outputCont(input);
                                                                          }));

            IMessage result = null;
            sut.Result += _ => result = _;

            sut.Process(task);

            Assert.AreSame(msg, result);
        }
Exemplo n.º 3
0
        public void Operation_with_multiple_outputs()
        {
            var sut = new Execute_task();

            var msg = new Message("x.in", "hello");
            var task = new Task(msg,
                                new Operation("x", (input, outputCont, _) => {
                                                                          		outputCont(new Message("1", input.Data.ToString() + "x"));
                                                                                outputCont(new Message("2", input.Data.ToString() + "y"));
                                                                          }));

            var results = new List<IMessage>();
            sut.Result += _ => results.Add(_);

            sut.Process(task);

            Assert.AreEqual("1", results[0].Port.Fullname);
            Assert.AreEqual("hellox", results[0].Data.ToString());
            Assert.AreEqual("2", results[1].Port.Fullname);
            Assert.AreEqual("helloy", results[1].Data.ToString());
        }
Exemplo n.º 4
0
        public Process_message()
        {
            // Build
            _map = new Map_message_to_input_ports();
            var output = new Output_result();
            _create = new Create_task();
            var exec = new Execute_task();
            var nest = new Nest_message_flow();

            // Bind
            _process += _map.Process;
            _map.Result += _ => Message(_);
            _map.Result += output.Process;
            output.Result += _ => Result(_);
            output.Continue +=_create.Process;
            _create.Result += exec.Process;
            _create.UnknownOperation += nest.Process;
            exec.Result += _ => Continue(_);
            exec.HandledException += _ => Continue(_);
            exec.UnhandledException += _ => UnhandledException(_);
            nest.Result += _map.Process;

            _execute += exec.Process;
        }