public void DocumentStorageTest_Load() { using (var client = new StorageServiceClient()) { Stopwatch sw = new Stopwatch(); sw.Start(); //int testContentLength = 1024 * 1024 * 100;// 100 Mb int testContentLength = 1024 * 1024;// 1 Mb MemoryStream memoryStream = new MemoryStream(); Random r = new Random(); for (int i = 0; i < testContentLength; i++) { memoryStream.WriteByte((byte)r.Next(0, 255)); } memoryStream.Position = 0; Trace.WriteLine(String.Format("Fill array at [{0}] ms", sw.ElapsedMilliseconds)); sw.Restart(); Guid documentId = Guid.NewGuid(); client.StoreDocumentStream(documentId, memoryStream); Trace.WriteLine(String.Format("Storedocument at [{0}] ms", sw.ElapsedMilliseconds)); //Assert.IsTrue(5000 >= sw.ElapsedMilliseconds); //5 s max DocumentInfo documentInfo = client.GetDocumentInfo(documentId); Assert.IsNull(documentInfo); Assert.IsTrue(client.IsDocumentExist(documentId)); client.Delete(documentId); Assert.IsFalse(client.IsDocumentExist(documentId)); } }
public void DocumentStorageTest_Base() { using (var client = new StorageServiceClient()) { byte[] testFileContent = ASCIIEncoding.Default.GetBytes("Test file content"); Stream s = new MemoryStream(testFileContent); Guid documentId = client.BeginStoreDocument(new DocumentInfo { Name = "DocName", Size = testFileContent.Length, IsEncrypted = false }); client.StoreDocumentStream(documentId, s); using (Stream documentStream = client.GetDocumentStream(documentId)) { using (MemoryStream ms = new MemoryStream()) { documentStream.CopyTo(ms); byte[] outFileContent = ms.ToArray(); CollectionAssert.AreEqual(testFileContent, outFileContent); } } DocumentInfo documentInfo = client.GetDocumentInfo(documentId); Assert.AreEqual("DocName", documentInfo.Name); Assert.AreEqual(testFileContent.Length, documentInfo.Size); Assert.IsTrue(client.IsDocumentExist(documentId)); client.Delete(documentId); documentInfo = client.GetDocumentInfo(documentId); Assert.IsNull(documentInfo); Assert.IsFalse(client.IsDocumentExist(documentId)); } }