private void DumpClassDiskSpaceInfo(bool isLocal) { Console.WriteLine("\n=== TEST {0} ===", isLocal ? UnitTestConstants.Local : UnitTestConstants.Network); var tempPath = UnitTestConstants.SysDrive; if (!isLocal) { tempPath = Path.LocalToUnc(tempPath); } Console.WriteLine("\nInput Path: [{0}]", tempPath); var cnt = 0; var errorCount = 0; // Get only .IsReady drives. foreach (var drv in Directory.EnumerateLogicalDrives(false, true)) { if (drv.DriveType == DriveType.NoRootDirectory) { continue; } var drive = isLocal ? drv.Name : Path.LocalToUnc(drv.Name); UnitTestConstants.StopWatcher(true); try { // null (default) == All information. var dsi = drv.DiskSpaceInfo; var report = UnitTestConstants.Reporter(true); Console.WriteLine("\n#{0:000}\tInput Path: [{1}]{2}", ++cnt, drive, report); Assert.IsTrue(UnitTestConstants.Dump(dsi, -26)); Assert.AreNotEqual(0, dsi.BytesPerSector); Assert.AreNotEqual(0, dsi.SectorsPerCluster); Assert.AreNotEqual(0, (int)dsi.TotalNumberOfClusters); Assert.AreNotEqual(0, (int)dsi.TotalNumberOfBytes); if (drv.DriveType == DriveType.CDRom) { Assert.AreEqual(0, (int)dsi.FreeBytesAvailable); Assert.AreEqual(0, dsi.NumberOfFreeClusters); Assert.AreEqual(0, (int)dsi.TotalNumberOfFreeBytes); } else { Assert.AreNotEqual(0, (int)dsi.FreeBytesAvailable); Assert.AreNotEqual(0, dsi.NumberOfFreeClusters); Assert.AreNotEqual(0, (int)dsi.TotalNumberOfFreeBytes); } // false == Size information only. dsi = Volume.GetDiskFreeSpace(drive, false); Assert.AreEqual(0, dsi.BytesPerSector); Assert.AreEqual(0, dsi.NumberOfFreeClusters); Assert.AreEqual(0, dsi.SectorsPerCluster); Assert.AreEqual(0, (int)dsi.TotalNumberOfClusters); // true == Cluster information only. dsi = Volume.GetDiskFreeSpace(drive, true); Assert.AreEqual(0, (int)dsi.FreeBytesAvailable); Assert.AreEqual(0, (int)dsi.TotalNumberOfBytes); Assert.AreEqual(0, (int)dsi.TotalNumberOfFreeBytes); } catch (Exception ex) { Console.WriteLine("\n\nCaught (unexpected) {0}: [{1}]", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, " ")); errorCount++; } } if (cnt == 0) { Assert.Inconclusive("Nothing was enumerated, but it was expected."); } Assert.AreEqual(0, errorCount, "No errors were expected."); Console.WriteLine(); }