//[TestMethod] public void Close() { try { string requestToken; WSModelProcessor processor = PostRequest(out requestToken); processor.Close("1"); } catch (Exception e) { Assert.Fail(e.Message, e); } }
//[TestMethod] public void Start() { try { string requestToken; WSModelProcessor processor = PostRequest(out requestToken); MemoryStream docStream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SQL_TEXT)); processor.RequestDocument("1", "0", docStream); docStream.Close(); processor.Start("1", false); processor.Close("1"); } catch (Exception e) { Assert.Fail(e.Message, e); } }
private WSModelProcessor PostRequest(out string requestToken) { WSModelProcessor processor = new WSModelProcessor(); IDictionary <string, object> settings = new Dictionary <string, object>(); IDictionary <string, string> requestProperties = new Dictionary <string, string>(); processor.Settings = settings; processor.SetRequestProperties(REQUEST_ID, requestProperties); Document[] desiredDocuments; settings.Add("ServiceURL", SERVICE_URL); Document[] requestDocuments = new Document[1]; requestDocuments[0] = new Document("0", "text/plain", "SQL Text"); requestDocuments[0].IsViewable = true; //requestDocuments[0].Size = (int) new FileInfo(@"C:\Users\daniel\Documents\drn\UploadSequenceDiagram.jpg").Length; requestDocuments[0].Size = SQL_TEXT.Length; processor.Request(REQUEST_ID, null, null, requestDocuments, out requestProperties, out desiredDocuments); requestToken = requestProperties["RequestToken"]; return(processor); }
//[TestMethod] public void Status() { try { string requestToken; WSModelProcessor processor = PostRequest(out requestToken); MemoryStream docStream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SQL_TEXT)); processor.RequestDocument("1", "0", docStream); docStream.Close(); processor.Start("1", false); RequestStatus status = processor.Status("1"); Assert.AreEqual(RequestStatus.StatusCode.Complete, status.Code); //Assert.AreEqual("Done. Wancheng. Finito.", status.Message); processor.Close("1"); } catch (Exception e) { Assert.Fail(e.Message, e); } }
//[TestMethod] public void Response() { try { string requestToken; WSModelProcessor processor = PostRequest(out requestToken); MemoryStream docStream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SQL_TEXT)); processor.RequestDocument("1", "0", docStream); docStream.Close(); processor.Start("1", false); while (processor.Status("1").Code != RequestStatus.StatusCode.Complete) { ; } Document[] documents = processor.Response("1"); processor.Close("1"); } catch (Exception e) { Assert.Fail(e.Message, e); } }
//[TestMethod] public void ResponseDocument() { try { string requestToken; WSModelProcessor processor = PostRequest(out requestToken); MemoryStream docStream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SQL_TEXT)); processor.RequestDocument("1", "0", docStream); docStream.Close(); processor.Start("1", false); while (processor.Status("1").Code != RequestStatus.StatusCode.Complete) { ; } Document[] documents = processor.Response("1"); //FileStream outStream = new FileStream(@"C:\Users\daniel\tmp\New-" + documents[0].Filename, FileMode.Create); Stream contentStream; processor.ResponseDocument("1", "0", out contentStream, documents[0].Size); using (StreamReader reader = new StreamReader(contentStream)) { string datasetXml = reader.ReadToEnd(); } //int bytesRead = 0; //byte[] buffer = new byte[5000]; //while ((bytesRead = contentStream.Read(buffer, 0, 5000)) > 0) //{ // //outStream.Write(buffer, 0, 5000); //} contentStream.Close(); //outStream.Close(); processor.Close("1"); } catch (Exception e) { Assert.Fail(e.Message, e); } }