public void ProcessDocumentTestInvalidData() { Console.WriteLine("ProcessDocumentTestInvalidData"); string xml = "</////trtgrg xml version=\"1.0\"?><doc></doc>"; Assert.Throws <XmlException>(() => ProcessDocument.GetProcess(xml, "XML")); }
public void ProcessTest() { Console.WriteLine("ProcessTest"); string xml = "<?xml version=\"1.0\"?><doc></doc>"; string type = "XML"; Assert.IsNotNull(ProcessDocument.GetProcess(xml, type)); }
public void ProcessDocumentTestJSONReturnsTypeOfNode() { Console.WriteLine("ProcessDocumentTestJSONReturnsTypeOfNode"); string json = "{ 'name':'jones'}"; string type = "JSON"; ProcessDocument pro = ProcessDocument.GetProcess(json, type); Assert.AreEqual(typeof(Node), pro.ProcessParallel().GetType()); }
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()); }
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()); }
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()); }
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()); }
public void TestingCorrectXML() { Console.WriteLine("TestingCorrectXML"); string xml = "<?xml version=\"1.0\"?><doc></doc>"; string type = "XML"; ProcessDocument process = ProcessDocument.GetProcess(xml, type); Node test = new Node(); test.Name = "doc"; test.Number = 1; test.Visited = true; Node n = process.ProcessParallel(); Assert.AreEqual(test.Value, n.Value); Assert.AreEqual(test.Name, n.Name); Assert.AreEqual(test.Children.Count, n.Children.Count); Assert.AreEqual(test.Visited, n.Visited); }
public void TestingCorrectJSON() { Console.WriteLine("TestingCorrectJSON"); string json = "{ 'name':'jones'}"; string type = "JSON"; ProcessDocument process = ProcessDocument.GetProcess(json, type); Node root = new Node(); root.Name = "name"; root.Number = 1; root.Visited = true; root.Value = "jones"; Node n = process.ProcessParallel(); Assert.AreEqual(root.Value, n.Value); Assert.AreEqual(root.Name, n.Name); Assert.AreEqual(root.Visited, n.Visited); }
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); }
public void ProcessTestNull() { Console.WriteLine("ProcessTestNull"); Assert.Throws <ArgumentException>(() => ProcessDocument.GetProcess(null, null)); }
/// <summary> /// Handles a POST request. /// </summary> /// <param name="req">The request to be processed.</param> /// <returns>A Response object to send to the user</returns> private Response HandlePost(HttpListenerRequest req) { JObject eRes = new JObject(); if (SegmentNormalize(req.RawUrl).Equals("Process")) { if (req.HasEntityBody) { Request r = null; try { r = GetData(req); if (r == null) { return(Response.GetInvalidRequestResponse()); } } catch { return(Response.GetInvalidRequestResponse()); } try { Validation.GetInstance().CheckDocument(r.Data, r.Type); } catch (Exception e) { eRes.Add("Error", e.Message); return(Response.GetErrorResponse(eRes.ToString())); } string id = Guid.NewGuid().ToString(); ProcessDocument pro = ProcessDocument.GetProcess(r.Data, r.Type); Node n = pro.ProcessParallel(); Output o = new Output(n); //new output object try { CacheManager.GetInstance().saveFile(id, JsonConvert.SerializeObject(n)); JObject response = new JObject(); n = null; //remove node as its completed; response.Add("filename", id); response.Add("grid", o.CreateGrid()); response.Add("view", o.CreateView()); byte[] bytes = Encoding.UTF8.GetBytes(response.ToString()); return(Response.GetResponse(200, "application/json", bytes)); } catch (Exception e) { Logger.GetInstance().WriteError(e.Message); eRes.Add("Error", "Error Creating Response"); return(Response.GetErrorResponse(eRes.ToString())); } } eRes.Add("Error", "No File Recieved By Server"); return(Response.GetErrorResponse(eRes.ToString())); } else if (req.RawUrl.Equals("/Output")) { return(Response.GetInvalidRequestResponse()); } else { return(Response.GetInvalidRequestResponse()); } }