예제 #1
0
        public void CreateDiffTest()
        {
            const int sz = 0x03010400;

            try
            {
                using (var vhdp = VirtualDisk.Create(tmpfn, sz))
                    using (var vhd = VirtualDisk.CreateDifferencing(tmpcfn, tmpfn))
                    {
                        Assert.That(System.IO.File.Exists(tmpcfn));
                        Assert.That(System.IO.File.Exists(tmpfn));
                        Assert.That(System.IO.File.Exists(tmpfn));
                        Assert.That(vhd.Attached, Is.False);
                        Assert.That(vhd.BlockSize, Is.EqualTo(0x200000));
                        Assert.That(vhd.DiskType, Is.EqualTo(VirtualDisk.DeviceType.Vhd));
                        Assert.That(vhd.Enabled, Is.False);
                        //Assert.That(vhd.FragmentationPercentage, Is.Zero); // must be non-differencing
                        Assert.That(vhd.Identifier, Is.Not.EqualTo(Guid.Empty));
                        Assert.That(vhd.Is4kAligned);
                        Assert.That(vhd.IsLoaded, Is.False);
                        Assert.That(vhd.IsRemote, Is.False);
                        Assert.That(vhd.LogicalSectorSize, Is.EqualTo(0x200));
                        //Assert.That(vhd.MostRecentId, Is.Null.Or.Empty);
                        Assert.That(vhd.NewerChanges, Is.False);
                        Assert.That(vhd.ParentBackingStore, Is.EqualTo(tmpfn));        // must be differencing
                        Assert.That(vhd.ParentIdentifier, Is.Not.EqualTo(Guid.Empty)); // must be differencing
                        Assert.That(vhd.ParentPaths, Is.Null);                         // must be differencing
                        Assert.That(vhd.ParentTimeStamp, Is.Zero);                     // must be differencing
                        //TestContext.WriteLine(vhd.PhysicalPath); // must be attached
                        Assert.That(vhd.PhysicalSectorSize, Is.EqualTo(0x200));
                        Assert.That(vhd.PhysicalSize, Is.LessThan(sz));
                        Assert.That(vhd.ProviderSubtype, Is.EqualTo(VirtualDisk.Subtype.Differencing));
                        Assert.That(vhd.SectorSize, Is.EqualTo(0x200));
                        //Debug.WriteLine(vhd.SmallestSafeVirtualSize); // must have file system
                        Assert.That(vhd.VendorId, Is.Not.EqualTo(Guid.Empty));
                        Assert.That(vhd.VhdPhysicalSectorSize, Is.EqualTo(0x200));
                        Assert.That(vhd.VirtualDiskId, Is.Not.EqualTo(Guid.Empty));
                        Assert.That(vhd.VirtualSize, Is.EqualTo(sz));
                    }
            }
            finally
            {
                System.IO.File.Delete(tmpcfn);
                System.IO.File.Delete(tmpfn);
            }
        }
예제 #2
0
        public void MergeTest()
        {
            const int sz = 0x03010400;

            try
            {
                using (var vhdp = VirtualDisk.Create(tmpfn, sz))
                    Assert.That(System.IO.File.Exists(tmpfn));
                using (var vhd = VirtualDisk.CreateDifferencing(tmpcfn, tmpfn))
                {
                    Assert.That(System.IO.File.Exists(tmpcfn));
                    vhd.Merge(1, 2);
                }
            }
            finally
            {
                System.IO.File.Delete(tmpcfn);
                System.IO.File.Delete(tmpfn);
            }
        }