public void WillCopyMetadataFromSourceWherePresent() { var buffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, SourceBlobName); sourceBlob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); sourceBlob.Metadata["thing"] = "something"; sourceBlob.Properties.ContentType = "whatever"; sourceBlob.SetMetadata(); sourceBlob.SetProperties(); var destinationBlob = new StandaloneAzureBlockBlob(BasePath, DestinationBlobName); destinationBlob.StartCopyFromBlob(sourceBlob); destinationBlob.FetchAttributes(); new { Metadata = new Dictionary<string, string> { {"thing", "something"} }, Properties = new { ContentType = "whatever", Length = (long) 12 } }.ToExpectedObject().ShouldMatch(destinationBlob); }
public void CanUploadContentFromFullByteArray(string blobName) { var blob = new StandaloneAzureBlockBlob(BasePath, blobName); blob.UploadFromByteArrayAsync(Encoding.UTF8.GetBytes("File content")).Wait(); Assert.Equal("File content", File.ReadAllText(blob.Uri.LocalPath)); }
public void CopyStateIsSuccessAfterCopy() { var buffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, SourceBlobName); sourceBlob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); var destinationBlob = new StandaloneAzureBlockBlob(BasePath, DestinationBlobName); destinationBlob.StartCopyFromBlob(sourceBlob); }
public void CanUploadContentFromByteArrayWithRangeSpecifier(int index, int count, string expectedContent, string blobName) { var buffer = Encoding.UTF8.GetBytes("File content"); var blob = new StandaloneAzureBlockBlob(BasePath, blobName); blob.UploadFromByteArrayAsync(buffer, index, count).Wait(); Assert.Equal(expectedContent, File.ReadAllText(blob.Uri.LocalPath)); }
public void CanCopyBlob() { var buffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, SourceBlobName); sourceBlob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); var destinationBlob = new StandaloneAzureBlockBlob(BasePath, DestinationBlobName); destinationBlob.StartCopyFromBlob(sourceBlob); Assert.Equal("File content", File.ReadAllText(destinationBlob.Uri.LocalPath)); }
public void CanDeleteBlob(string blobName) { var buffer = Encoding.UTF8.GetBytes("File content"); var blob = new StandaloneAzureBlockBlob(BasePath, blobName); blob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); blob.Delete(); Assert.False(File.Exists(blob.Uri.LocalPath)); }
public void CanOverwriteBlob(string source, string destination) { var sourceBuffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, source); sourceBlob.UploadFromByteArrayAsync(sourceBuffer, 0, sourceBuffer.Length).Wait(); var originalContentBuffer = Encoding.UTF8.GetBytes("Original content"); var destinationBlob = new StandaloneAzureBlockBlob(BasePath, destination); destinationBlob.UploadFromByteArrayAsync(originalContentBuffer, 0, originalContentBuffer.Length).Wait(); destinationBlob.StartCopyFromBlob(sourceBlob.Uri); Assert.Equal("File content", File.ReadAllText(destinationBlob.Uri.LocalPath)); }
public void CanDeleteBlobMetadata(string blobName) { var buffer = Encoding.UTF8.GetBytes("File content"); var blob = new StandaloneAzureBlockBlob(BasePath, blobName); blob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); blob.Metadata["thing"] = "something"; blob.SetMetadata(); blob.Delete(); Assert.False(File.Exists(Path.Combine(BasePath, ".meta", blobName))); }
public ListMetadataTests() : base(DirectoryType.Container) { var flatBlob = new StandaloneAzureBlockBlob(BasePath, "flat"); flatBlob.UploadFromByteArrayAsync(Encoding.UTF8.GetBytes("flat")); flatBlob.Metadata["thing"] = "flat"; flatBlob.SetMetadata(); var withPath = new StandaloneAzureBlockBlob(BasePath, @"random\path\blob"); withPath.UploadFromByteArrayAsync(Encoding.UTF8.GetBytes("withPath")); withPath.Metadata["thing"] = "withPath"; withPath.SetMetadata(); }
public async Task CanDownloadBlboToStreamAsync(string blobName) { var blob = new StandaloneAzureBlockBlob(BasePath, blobName); await blob.UploadFromByteArrayAsync(Encoding.UTF8.GetBytes("Streamable content")); using (var memoryStream = new MemoryStream()) { await blob.DownloadToStreamAsync(memoryStream); memoryStream.Position = 0; using (var streamReader = new StreamReader(memoryStream)) { Assert.Equal("Streamable content", streamReader.ReadToEnd()); } } }
public void CopyStateIsFailedIfBlobLocked(string source, string destination) { var buffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, source); sourceBlob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); using (new FileStream(sourceBlob.Uri.LocalPath, FileMode.Append, FileAccess.Write, FileShare.None)) { var destinationBlob = new StandaloneAzureBlockBlob(BasePath, destination); destinationBlob.StartCopyFromBlob(sourceBlob.Uri); new { Status = CopyStatus.Failed, StatusDescription = new NotNullComparison() }.ToExpectedObject().ShouldMatch(destinationBlob.CopyState); } }
public void WillNotCopyMetadataWhereItDoesNotExist() { var buffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, SourceBlobName); sourceBlob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); var destinationBlob = new StandaloneAzureBlockBlob(BasePath, DestinationBlobName); destinationBlob.StartCopyFromBlob(sourceBlob); Assert.False(File.Exists(Path.Combine(BasePath, ".meta", DestinationBlobName))); }
public void WillRemoveExistingMetadataWhereSourceDoesNotHaveMetadata(string source, string destination) { var buffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, source); sourceBlob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); var originalContentBuffer = Encoding.UTF8.GetBytes("Original content"); var destinationBlob = new StandaloneAzureBlockBlob(BasePath, destination); destinationBlob.UploadFromByteArrayAsync(originalContentBuffer, 0, originalContentBuffer.Length).Wait(); destinationBlob.Metadata["thing"] = "other thing"; destinationBlob.SetMetadata(); destinationBlob.StartCopyFromBlob(sourceBlob.Uri); Assert.False(File.Exists(Path.Combine(BasePath, ".meta", destination))); }
public void CopyStateIsSuccessAfterCopy(string source, string destination) { var buffer = Encoding.UTF8.GetBytes("File content"); var sourceBlob = new StandaloneAzureBlockBlob(BasePath, source); sourceBlob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); var destinationBlob = new StandaloneAzureBlockBlob(BasePath, destination); destinationBlob.StartCopyFromBlob(sourceBlob.Uri); Assert.Equal(CopyStatus.Success, destinationBlob.CopyState.Status); }
protected static void CreateBlobContent(StandaloneAzureBlockBlob blob) { var buffer = Encoding.UTF8.GetBytes("Some content"); blob.UploadFromByteArrayAsync(buffer, 0, buffer.Length).Wait(); }