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