Exemplo n.º 1
0
        public IActionResult Post(NewItemRequest dto)
        {
            _logger.LogInformation("New request");

            _backgroundJobs.Enqueue(() => _processDocument.Process(dto));

            return(Ok());
        }
Exemplo n.º 2
0
        public void ProcessDocumentTestXMLReturnsTypeOfNode()
        {
            Console.WriteLine("ProcessDocumentTestXMLReturnsTypeOfNode");
            string          xml  = "<?xml version=\"1.0\"?><doc></doc>";
            string          type = "XML";
            ProcessDocument pro  = ProcessDocument.GetProcess(xml, type);

            Assert.AreEqual(typeof(Node), pro.Process().GetType());
        }
Exemplo n.º 3
0
        public IActionResult Post(NewFileToProcess dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Missing parameters"));
            }

            _backgroundJobs.Enqueue(() => _processDocument.Process(dto));

            return(Ok());
        }
Exemplo n.º 4
0
        public void OutputTest()
        {
            Console.WriteLine("OutputTest");
            string          xml     = "<?xml version=\"1.0\"?><doc></doc>";
            string          type    = "XML";
            ProcessDocument process = ProcessDocument.GetProcess(xml, type);
            Node            n       = process.Process();
            Output          output  = new Output(n);

            Assert.IsNotNull(output);
            Assert.AreEqual(typeof(Output), output.GetType());
        }
Exemplo n.º 5
0
        public void CreateGridTest()
        {
            Console.WriteLine("CreateGridTest");
            JObject expected = JObject.Parse("{\"text\":\"doc\",\"id\":1,\"state\":{\"selected\":true}}");
            string  xml      = "<?xml version=\"1.0\"?><doc></doc>";
            string  type     = "XML";

            ProcessDocument process = ProcessDocument.GetProcess(xml, type);
            Node            n       = process.Process();
            Output          output  = new Output(n);

            Assert.AreEqual(expected, output.CreateGrid());
        }
Exemplo n.º 6
0
        public void Must_process_all_pages_from_document()
        {
            const string filePath      = "file.pdf";
            const int    numberOfPages = 2;
            const string pageText1     = "Text 1";
            const string pageText2     = "Text 2";

            A.CallTo(() => _fileManager.Download(_newFileToProcess.Url)).Returns(filePath);
            A.CallTo(() => _fileManager.GetNumberOfPages(filePath)).Returns(numberOfPages);
            A.CallTo(() => _extractionManager.Extract(filePath, 1)).Returns(pageText1);
            A.CallTo(() => _extractionManager.Extract(filePath, 2)).Returns(pageText2);

            _processDocument.Process(_newFileToProcess).Wait();

            A.CallTo(() => _callback.Send(
                         A <DocumentResultResponse> .That.Matches(d => d.Pages.Count == numberOfPages),
                         _newFileToProcess.CallbackUrl));
            A.CallTo(() => _callback.Send(
                         A <DocumentResultResponse> .That.Matches(d => d.Pages[0].Text == pageText1),
                         _newFileToProcess.CallbackUrl));
            A.CallTo(() => _callback.Send(
                         A <DocumentResultResponse> .That.Matches(d => d.Pages[1].Text == pageText2),
                         _newFileToProcess.CallbackUrl));
        }
Exemplo n.º 7
0
        public void CreateViewTest()
        {
            Console.WriteLine("CreateViewTest");
            string expected = "<div class='text-center ui-layout-center ui-layout-pane ui-layout-pane-center'><div style ='display:inline-block' class='ui-selectable ui-droppable'><div id='1'class='node type ui-draggable ui-selectee' style='left:100px; top:130px;'><div class='head'><span><button class='nameBtn' onclick='GetNode(1)'>doc</button></span></div></div></div></div></div>";
            string xml      = "<?xml version=\"1.0\"?><doc></doc>";
            string type     = "XML";

            ProcessDocument process = ProcessDocument.GetProcess(xml, type);
            Node            n       = process.Process();
            Output          output  = new Output(n);

            Console.WriteLine(expected);
            Console.WriteLine(output.CreateView());
            Assert.AreEqual(expected, output.CreateView());
        }
Exemplo n.º 8
0
        public void TestingSingleThreadAndMultiThreadSimularity(string json)
        {
            Console.WriteLine("TestingSingleThreadAndMultiThreadSimularity");
            string          type    = "JSON";
            ProcessDocument process = ProcessDocument.GetProcess(json, type);

            Console.WriteLine(process);

            Node n = process.Process();

            process = ProcessDocument.GetProcess(json, type);
            Node n2 = process.ProcessParallel();

            Console.WriteLine(process);

            Assert.AreEqual(n2.Value, n.Value);
            Assert.AreEqual(n2.Name, n.Name);
            Assert.AreEqual(n2.Children.Count, n.Children.Count);
            Assert.AreEqual(n2.Visited, n.Visited);
        }