Пример #1
0
        public void Test1()
        {
            // plain pipeline definition objects
            PipelineDefinition <string, string> concat4As = new PipelineDefinition <string, string>();

            concat4As.Append <AddA>();
            concat4As.Append <AddA>();
            concat4As.Append <AddA>();
            concat4As.Append <AddA>();

            concat4As.Append <AddB>();
            concat4As.Append <AddB>();
            concat4As.Append <AddB>();
            concat4As.Append <AddB>();

            // ioc fake for pipe construction
            IServiceProvider serviceProviderMock = Substitute.For <IServiceProvider>();

            serviceProviderMock.GetService(Arg.Is(typeof(AddA))).Returns(new AddA());

            serviceProviderMock.GetService(Arg.Is(typeof(AddB))).Returns(new AddB());

            IPipeline <string, string> pipe = new AsyncPipeline <string, string>(concat4As, serviceProviderMock);

            Stopwatch sw = new Stopwatch();

            sw.Start();

            string result = (string)pipe.Process("");

            sw.Stop();

            Assert.True(result == "AAAABBBB");
        }