public void Resize_Vhd_Blob_Shrink() { var firstSizeInGb = 2; var newSizeInGb = 1; var vhdFilePath = "TestDisk-Shrink.vhd"; var containerName = "test-container"; // First create the fixed VHD file VhdHelper.CreateVhdDisk(false, firstSizeInGb, vhdFilePath, "Testing Shrink Disk"); var vhdBlobUri = AzureStorageEmulatorHelper.UploadVhdFileToContainer(containerName, vhdFilePath); // Then resize the VHD file var resizeVhdHelper = new ResizeVhdHelper(); var firstResult = resizeVhdHelper.ResizeVhdBlob(newSizeInGb, vhdBlobUri, accountName, accountKey); var finalResult = ResizeResult.Error; if (firstResult == ResizeResult.Shrink) { resizeVhdHelper.IsExpand = false; finalResult = resizeVhdHelper.DoResizeVhdBlob(); } var length = AzureStorageEmulatorHelper.GetVhdSizeInContainer(vhdBlobUri); // Clean the files in the container and the local file system AddCleanupAction(() => AzureStorageEmulatorHelper.DeleteVhdFileInContainer(containerName, vhdBlobUri)); AddCleanupAction(() => File.Delete(vhdFilePath)); Assert.IsTrue(firstResult == ResizeResult.Shrink); Assert.IsTrue(finalResult == ResizeResult.Success); Assert.IsTrue(newSizeInGb == (int)ByteSize.FromBytes(length).GigaBytes); }
public void Resize_Vhd_Blob_Dynamic_Disk() { var newSizeInGb = 1; var vhdFilePath = "TestDisk-Dynamic.vhd"; var containerName = "test-container"; // First create the dynamic VHD file VhdHelper.CreateVhdDisk(true, newSizeInGb, vhdFilePath, "Testing Disk"); var vhdBlobUri = AzureStorageEmulatorHelper.UploadVhdFileToContainer(containerName, vhdFilePath); // Then resize the VHD file var resizeVhdHelper = new ResizeVhdHelper(); var result = resizeVhdHelper.ResizeVhdBlob(newSizeInGb, vhdBlobUri, accountName, accountKey); var length = AzureStorageEmulatorHelper.GetVhdSizeInContainer(vhdBlobUri); // Clean the files in the container and the local file system AddCleanupAction(() => AzureStorageEmulatorHelper.DeleteVhdFileInContainer(containerName, vhdBlobUri)); AddCleanupAction(() => File.Delete(vhdFilePath)); Assert.IsTrue(result == ResizeResult.Error); Assert.IsTrue(ByteSize.FromGigaBytes(newSizeInGb) != ByteSize.FromBytes(length)); }