public void FileBlobTests_E2E_Test() { var testFile = new FileInfo(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())); IPersistentBlob blob = new FileBlob(testFile.FullName); var data = Encoding.UTF8.GetBytes("Hello, World!"); IPersistentBlob blob1 = blob.Write(data); var blobContent = blob.Read(); Assert.Equal(testFile.FullName, ((FileBlob)blob1).FullPath); Assert.Equal(data, blobContent); blob1.Delete(); Assert.False(testFile.Exists); }
public void FileBlobTests_ReadFailsOnAlreadyLeasedFile() { var testFile = new FileInfo(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())); FileBlob blob1 = new FileBlob(testFile.FullName); FileBlob blob2 = new FileBlob(testFile.FullName); var data = Encoding.UTF8.GetBytes("Hello, World!"); blob1.Write(data); var leasePeriodMilliseconds = 10000; // Leased by another thread/process/object blob2.Lease(leasePeriodMilliseconds); // Read should fail as file is leased Assert.Null(blob1.Read()); // Clean up blob2.Delete(); }