using Chronos.Core.Windows.Devices;
using Chronos.Testing;
namespace Chronos.Core.Windows.Tests.Devices;
///
/// The free space of a folder's volume as a conversion checks it on the desktop (owner review 2, R7): a network share's too,
/// which cannot measure. Apart from , which enumerate every volume.
///
public sealed class FreeSpaceTests(TestContext context)
{
[Test]
[WindowsOnly]
public void AFolderIsMeasuredOnItsVolumeAndAMissingOneIsNot()
{
var folder = context.CreateTempDirectory("free");
Assert.Greater(Assert.NotNull(VolumeInfo.FreeBytesAt(folder)), 0);
Assert.Greater(Assert.NotNull(VolumeInfo.FreeBytesAt(folder + Path.DirectorySeparatorChar)), 0);
Assert.Null(VolumeInfo.FreeBytesAt(Path.Combine(folder, "missing", "deeper")));
}
[Test]
[WindowsOnly]
public void AFolderOnAShareIsMeasuredWhereTheDriveCannotBe()
{
var folder = Path.GetFullPath(context.CreateTempDirectory("share"));
var share = $@"\\localhost\{char.ToLowerInvariant(folder[0])}$" + folder[2..];
if (!Directory.Exists(share)) TestContext.Skip("This PC has no administrative share for the test folder.");
Assert.Throws(() => new DriveInfo(Path.GetPathRoot(share)!));
Assert.Greater(Assert.NotNull(VolumeInfo.FreeBytesAt(share)), 0);
}
}