Ejemplo n.º 1
0
        public void DrawTree_SamplesOfTreesDisplayed()
        {
            var u = new WorkUnit1A(null);

            var tree   = new WorkUnitTree(u);
            var paths1 = tree.AddNextNode(new WorkUnitTree(u))
                         .AddConditionalNodes((i, o) => ExecutionPath.Path1, new Dictionary <ExecutionPath, WorkUnitTree>
            {
                [ExecutionPath.Path1] = new WorkUnitTree(u),
                [ExecutionPath.Path2] = new WorkUnitTree(u),
                [ExecutionPath.Path3] = new WorkUnitTree(u)
            });

            paths1[ExecutionPath.Path1].AddNextNode(new WorkUnitTree(u));
            var path2 = paths1[ExecutionPath.Path2].AddConditionalNodes((i, o) => ExecutionPath.Path2, new Dictionary <ExecutionPath, WorkUnitTree>
            {
                [ExecutionPath.Path1] = new WorkUnitTree(u),
                [ExecutionPath.Path2] = new WorkUnitTree(u)
            });

            path2[ExecutionPath.Path1].AddNextNode(new WorkUnitTree(u)).AddNextNode(new WorkUnitTree(u)).AddNextNode(new WorkUnitTree(u));
            path2[ExecutionPath.Path2].AddConditionalNodes((i, o) => ExecutionPath.Path1, new Dictionary <ExecutionPath, WorkUnitTree>
            {
                [ExecutionPath.Path1] = new WorkUnitTree(u),
                [ExecutionPath.Path2] = new WorkUnitTree(u)
            });

            Console.WriteLine("Complete tree:");
            Console.WriteLine(tree.DrawTree(""));

            Console.WriteLine();
            Console.WriteLine("Execution path: Path1->Path2");
            Console.WriteLine(paths1[ExecutionPath.Path2].DrawTree(""));
        }
Ejemplo n.º 2
0
        private WebSiteParserA GetParserA()
        {
            var tree = new WorkUnitTree(workUnitsA[typeof(WorkUnit1A)]);

            tree.AddNextNode(new WorkUnitTree(workUnitsA[typeof(WorkUnit2A)]));

            return(new WebSiteParserA(tree));
        }
Ejemplo n.º 3
0
        public Site911Result Get([FromUri] string id)
        {
            var httpClient = new HttpClient();
            var tree       = new WorkUnitTree(new A0httpRequest(httpClient));

            tree.AddNextNode(new WorkUnitTree(new B0parseHtml()))
            .AddNextNode(new WorkUnitTree(new C0httpRequestPartDetails(httpClient)))
            .AddNextNode(new WorkUnitTree(new D0parseHtmlPartDetails()));

            var parser = new Site911Parser(tree);

            var result = parser.Parse(new Input {
                Id = id
            });

            return(result);
        }
Ejemplo n.º 4
0
        public void Parse_WorkUnitThrowsException_SaveToExceptionProperty()
        {
            var tree = new WorkUnitTree(new WuRoot());

            tree.AddNextNode(new WorkUnitTree(new Wu1()))
            .AddNextNode(new WorkUnitTree(new WorkUnitException()))
            .AddNextNode(new WorkUnitTree(new Wu2()));

            var parser = new WebSiteParser <IWorkUnit, ParserExecutorResult>(tree);

            var result = parser.Parse(new In {
                Id = "1"
            });

            var expected = JsonConvert.SerializeObject(new {
                UnitName = "WorkUnitException",
                Message  = "Exception in work unit",
                Path     = "WuRoot > Wu1 > WorkUnitException > "
            });

            Assert.AreEqual(expected, result.Exception);
        }