示例#1
0
        public void Executing_an_empty_chain_should_not_throw_exception()
        {
            var emptyChain = new PlainChain <Message>(new ILink <Message> [0]);

            var message = new Message();

            Assert.DoesNotThrow(() => emptyChain.ExecuteAll(message));
        }
示例#2
0
        public void Executing_am_empty_chain_should_not_result_anything()
        {
            var emptyChain = new PlainChain <Message>(new ILink <Message> [0]);

            var message = new Message();

            emptyChain.ExecuteAll(message);

            Results.Count.ShouldEqual(0);
        }
示例#3
0
        public void When_single_node_added_should_add_to_the_results_correctly()
        {
            var message = new Message {
                Name = "M1"
            };

            var c = new PlainChain <Message>(new ILink <Message>[]
            {
                new L1(),
            });

            c.ExecuteAll(message);

            Results.Count.ShouldEqual(1);

            Results.Index[0].ShouldEqual("L1: M1");
        }
示例#4
0
        public void Executing_an_emtpy_chain_should_run_closing_action()
        {
            var emptyChain = new PlainChain <Message>(new ILink <Message> [0]);

            emptyChain.SetClosingAction(m =>
            {
                Results.Add($"Closed: {m.Name}");
            });

            var message = new Message {
                Name = "SomeMessage"
            };

            emptyChain.ExecuteAll(message);

            Results.Count.ShouldEqual(1);
            Results.Index[0].ShouldEqual("Closed: SomeMessage");
        }
示例#5
0
        public void L3_should_stop_propagation()
        {
            var message = new Message {
                Name = "M1"
            };

            var c = new PlainChain <Message>(new ILink <Message>[]
            {
                new L3(),
                new L1(),
            });

            c.ExecuteAll(message);

            Results.Count.ShouldEqual(1);

            Results.Index[0].ShouldEqual("L3: M1");
        }
示例#6
0
        public void L4_should_stop_execution()
        {
            var message = new Message {
                Name = "M1"
            };

            var c = new PlainChain <Message>(new ILink <Message>[]
            {
                new L4(),
                new L1(),
            });

            c.SetClosingAction(m =>
            {
                Results.Add("ClosingMessage");
            });

            c.ExecuteAll(message);

            Results.Count.ShouldEqual(1);

            Results.Index[0].ShouldEqual("L4: M1");
        }