public void AppendContentStreamTest( string canonical_name, string localPath, string remoteFolderPath, string url, string user, string password, string repositoryId, string binding) { ISession session = DotCMISSessionTests.CreateSession(user, password, url, repositoryId, binding); IFolder folder = (IFolder)session.GetObjectByPath(remoteFolderPath); string filename = "testfile.txt"; Dictionary <string, object> properties = new Dictionary <string, object>(); properties.Add(PropertyIds.Name, filename); properties.Add(PropertyIds.ObjectTypeId, BaseTypeId.CmisDocument.GetCmisValue()); IDocument doc = null; try { doc = session.GetObjectByPath(remoteFolderPath.TrimEnd('/') + "/" + filename) as IDocument; if (doc != null) { doc.Delete(true); } } catch (Exception) { } string content = "test"; string expectedContent = string.Empty; doc = folder.CreateDocument(filename, content); expectedContent = content; Assert.That(doc.ContentStreamLength == content.Length, "returned document should have got content"); for (int i = 0; i < 10; i++) { doc = doc.AppendContent(content, i == 9) ?? doc; expectedContent += content; Assert.AreEqual(expectedContent.Length, doc.ContentStreamLength); } doc.AssertThatIfContentHashExistsItIsEqualTo(expectedContent); for (int i = 0; i < 10; i++) { doc = doc.AppendContent(content) ?? doc; expectedContent += content; Assert.AreEqual(expectedContent.Length, doc.ContentStreamLength); doc.AssertThatIfContentHashExistsItIsEqualTo(expectedContent); } doc.DeleteAllVersions(); }
public static bool VerifyThatIfTimeoutIsExceededContentHashIsEqualTo(this IDocument doc, string content, int timeoutInSeconds = 3600) { doc.AssertThatIfContentHashExistsItIsEqualTo(content); int loops = 0; while (doc.ContentStreamHash() == null && loops < timeoutInSeconds) { loops++; Thread.Sleep(1000); doc.Refresh(); doc.AssertThatIfContentHashExistsItIsEqualTo(content); if (doc.ContentStreamHash() != null) { return(true); } } return(false); }