public void Rename_Test() { //Arrange string expected = Guid.NewGuid().ToString("n"); //Arrange //load the user UserBean user = _bundledocsApi.Users.Me(); //choose a brief Brief brief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault(); //load the brief BriefBean loadedBrief = _bundledocsApi.Bundles.Get(brief.PartitionKey, brief.RowKey); //load the brief documents BriefDocument documentToRename = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey).Where(k => k.Type == "HEADER").FirstOrDefault().Children.Where(k => k.Type == "DOCUMENT").FirstOrDefault(); //Act //rename the section BriefDocument renamedDocument = _bundledocsApi.Documents.Rename(documentToRename.PartitionKey, documentToRename.RowKey, expected); //Assert Assert.AreEqual(expected, renamedDocument.Description); }
public void Download_Test() { //Arrange //load the user UserBean user = _bundledocsApi.Users.Me(); //find a brief to load Brief parentBrief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault(); //load the brief BriefBean loadedBrief = _bundledocsApi.Bundles.Get(parentBrief.PartitionKey, parentBrief.RowKey); //load the brief documents BriefDocument documentToDownload = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey).Where(k => k.Type == "HEADER").FirstOrDefault().Children.Where(k => k.Type == "DOCUMENT").FirstOrDefault(); //Act //download the document Stream myStream = _bundledocsApi.Documents.Download(documentToDownload.PartitionKey, documentToDownload.RowKey); //write the downloaded bundle to disk byte[] myFile = myStream.ReadToEnd(); string newFilePath = $@"{App.Default.TempFolder}{Guid.NewGuid().ToString("n")}.pdf"; File.WriteAllBytes(newFilePath, myFile); //Assert Assert.IsTrue(File.Exists(newFilePath)); //open the downloaded bundle Process.Start(newFilePath); }
public void Create_Test() { //Arrange bool expected = true; bool actual = false; //load the user UserBean user = _bundledocsApi.Users.Me(); //find a brief to load Brief briefToLoad = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault(); //load the brief BriefBean loadedBrief = _bundledocsApi.Bundles.Get(briefToLoad.PartitionKey, briefToLoad.RowKey); //load the brief documents IList <BriefDocument> briefDocuments = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey); //find a section to upload a document into BriefDocument uploadLocation = briefDocuments.Where(k => k.Type == "HEADER").FirstOrDefault(); //Act bool isSuccess = _bundledocsApi.Documents.Create(uploadLocation, App.Default.UploadFileLocation); //listen to the events back from the server to verify the document is uploaded and processed successfully actual = _bundledocsApi.Events.WaitForUploadToComplete(uploadLocation.ForeignKey); //Assert Assert.AreEqual(expected, actual); }
public void Rename_Test() { //Arrange string expected = Guid.NewGuid().ToString("n"); string actual = String.Empty; //Arrange //load the user UserBean user = _bundledocsApi.Users.Me(); //choose a brief Brief brief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault(); //load the brief BriefBean loadedBrief = _bundledocsApi.Bundles.Get(brief.PartitionKey, brief.RowKey); //load the brief documents BriefDocument sectionToRename = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey).Where(k => k.Type == "HEADER").FirstOrDefault(); //Act //rename the section BriefDocument renamedSection = _bundledocsApi.Sections.Rename(sectionToRename.PartitionKey, sectionToRename.RowKey, expected); actual = renamedSection.Description; //Assert Assert.AreEqual(expected, actual); }
public void Delete_Test() { //Arrange //load the user UserBean user = _bundledocsApi.Users.Me(); //choose a brief Brief brief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault(); //load the brief BriefBean loadedBrief = _bundledocsApi.Bundles.Get(brief.PartitionKey, brief.RowKey); //load the brief documents BriefDocument documentToDelete = _bundledocsApi.Bundles.Tree(loadedBrief.PartitionKey, loadedBrief.RowKey).Where(k => k.Type == "HEADER").FirstOrDefault().Children.Where(k => k.Type == "DOCUMENT").FirstOrDefault(); //Act //delete the document BriefDocument deletedDocument = _bundledocsApi.Documents.Delete(documentToDelete.PartitionKey, documentToDelete.RowKey); //Assert Assert.AreEqual(documentToDelete.RowKey, deletedDocument.RowKey); }
public void Create_Test() { //Arrange string expected = Guid.NewGuid().ToString("n"); string actual = String.Empty; //load the user UserBean user = _bundledocsApi.Users.Me(); //choose a brief Brief brief = user.Briefs.Where(k => k.PartitionKey == user.RowKey).FirstOrDefault(); //load the brief BriefBean loadedBrief = _bundledocsApi.Bundles.Get(brief.PartitionKey, brief.RowKey); //Act BriefDocument newSection = _bundledocsApi.Sections.Create(loadedBrief.PartitionKey, loadedBrief.RowKey, expected); actual = newSection.Description; //Assert Assert.AreEqual(expected, actual); }
public bool Create(BriefDocument parentSection, Stream fileStream, string fileName, bool isTitlePage = false) { bool isSuccess = false; try { //prepare the upload parameters UploadFile uploadFile = new UploadFile(); uploadFile.FileName = fileName; uploadFile.Stream = fileStream; uploadFile.ContentType = "application/octet-stream"; //prepare the upload parameters NameValueCollection uploadFileParameters = new NameValueCollection(); uploadFileParameters.Add("PartitionKey", parentSection.PartitionKey); uploadFileParameters.Add("ForeignKey", parentSection.ForeignKey); uploadFileParameters.Add("ParentRowKey", parentSection.RowKey); uploadFileParameters.Add("FileUploadKey", Guid.NewGuid().ToString()); uploadFileParameters.Add("FileUploadDate", DateTime.Now.ToLongDateString()); //upload the document if (isTitlePage) { isSuccess = _documents.UploadTitlePageDocument(_authorizationHeader, uploadFileParameters, uploadFile); } else { isSuccess = _documents.UploadDocument(_authorizationHeader, uploadFileParameters, uploadFile); } } catch { throw; } return(isSuccess); }
public bool Create(BriefDocument briefDocument, string fileLocation, string fileName = "", bool isTitlePage = false) { return(Create(briefDocument, File.OpenRead(fileLocation), String.IsNullOrEmpty(fileName?.Trim()) ? Path.GetFileName(fileLocation) : fileName?.Trim(), isTitlePage)); }