public void BuildEmptyDynamic() { DiskBuilder builder = new DiskBuilder(); builder.DiskType = DiskType.Dynamic; builder.Content = new SparseMemoryStream(); DiskImageFileSpecification[] fileSpecs = builder.Build("foo"); Assert.AreEqual(1, fileSpecs.Length); Assert.AreEqual("foo.vhdx", fileSpecs[0].Name); using (Disk disk = new Disk(fileSpecs[0].OpenStream(), Ownership.Dispose)) { Assert.AreEqual(0, disk.Content.Length); } }
public override DiskImageBuilder GetImageBuilder(string variant) { DiskBuilder builder = new DiskBuilder(); switch (variant) { case "fixed": builder.DiskType = DiskType.Fixed; break; case "dynamic": builder.DiskType = DiskType.Dynamic; break; default: throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown VHD disk variant '{0}'", variant), "variant"); } return builder; }
public override DiskImageBuilder GetImageBuilder(string variant) { DiskBuilder builder = new DiskBuilder(); switch (variant) { case "fixed": builder.DiskType = DiskType.Fixed; break; case "dynamic": builder.DiskType = DiskType.Dynamic; break; default: throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown VHD disk variant '{0}'", variant), "variant"); } return(builder); }
public void BuildDynamic() { DiskBuilder builder = new DiskBuilder(); builder.DiskType = DiskType.Dynamic; builder.Content = diskContent; DiskImageFileSpecification[] fileSpecs = builder.Build("foo"); Assert.AreEqual(1, fileSpecs.Length); Assert.AreEqual("foo.vhdx", fileSpecs[0].Name); using (Disk disk = new Disk(fileSpecs[0].OpenStream(), Ownership.Dispose)) { for (int i = 0; i < 8; ++i) { disk.Content.Position = i * 1024L * 1024; Assert.AreEqual(i, disk.Content.ReadByte()); } disk.Content.Position = 150 * 1024 * 1024; Assert.AreEqual(0xFF, disk.Content.ReadByte()); } }