Ejemplo n.º 1
1
        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);
            }
        }
Ejemplo n.º 2
0
        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());
            }
        }