Beispiel #1
0
        public void ThreeStepWithInputPoint()
        {
            List <string>          results = new List <string>();
            InputPoint <int>       s       = new InputPoint <int>();
            TaskNode <int, string> filter  = Helpers.GetFilter();

            EndPoint <string> n = Helpers.GetEndpoint(results);

            Flow flow = Helpers.ConnectStartFilterEnd(s, filter, n);

            flow.Start();
            s.Send(1, 2, 3, 4, 5, 6, 7, 8);
            s.Send(new int[] { 9, 10, 11, 12, 13, 14, 15 });
            flow.RunToCompletion();
            Assert.AreEqual(4, results.Count);
            Assert.AreEqual(15, filter.ItemsProcessed);
            Assert.AreEqual(RunStatus.Running, n.Status);

            s.CloseEntrance();
            flow.RunToCompletion();
            // at this point, the flow and some nodes may still be running or stopping,
            // the data items have left the flow, but the nodes can still be in the process of stopping
            Assert.Contains(n.Status, new List <RunStatus>()
            {
                RunStatus.Running, RunStatus.Stopping, RunStatus.Stopped
            });

            // after a small wait, everything should be in the Stopped status
            Thread.Sleep(100);
            Assert.AreEqual(RunStatus.Stopped, n.Status);
        }
Beispiel #2
0
        public void SortingValues()
        {
            InputPoint <int>    entry   = new InputPoint <int>();
            TaskNode <int, int> sorter  = StandardTasks.GetSortingFilter <int>();
            Collector <int>     collect = new Collector <int>();

            sorter.ItemProcessed += new EventHandler <TaskNode.ItemEventArgs>(sorter_ItemProcessed);

            Flow f = Flow.FromAsciiArt("a-->b-->c", entry, sorter, collect);

            f.Start();

            entry.Send(3, 7, 1, 9, 123, 2, 5, 3);
            entry.CloseEntrance();
            f.RunToCompletion();
            //Thread.Sleep(1000);
            Console.WriteLine("Last:" + f.GetStateSnapshot());
            Assert.AreEqual(8, collect.Items.Count);
            Assert.AreEqual(1, collect.Items[0]);
            Assert.AreEqual(3, collect.Items[3]);
        }
Beispiel #3
0
        public void ThreeStepWithInputPoint()
        {
            List<string> results = new List<string>();
            InputPoint<int> s = new InputPoint<int>();
            TaskNode<int, string> filter = Helpers.GetFilter();

            EndPoint<string> n = Helpers.GetEndpoint(results);

            Flow flow = Helpers.ConnectStartFilterEnd(s, filter, n);

            flow.Start();
            s.Send(1,2,3,4,5,6,7,8);
            s.Send(new int[]{9,10,11,12,13,14,15});
            flow.RunToCompletion();
            Assert.AreEqual(4, results.Count);
            Assert.AreEqual(15, filter.ItemsProcessed);
            Assert.AreEqual(RunStatus.Running, n.Status);

            s.CloseEntrance();
            flow.RunToCompletion();
            // at this point, the flow and some nodes may still be running or stopping,
            // the data items have left the flow, but the nodes can still be in the process of stopping
            Assert.Contains(n.Status, new List<RunStatus>(){RunStatus.Running , RunStatus.Stopping, RunStatus.Stopped});

            // after a small wait, everything should be in the Stopped status
            Thread.Sleep(100);
            Assert.AreEqual(RunStatus.Stopped, n.Status);
        }