public void TestInvert() { var result = new BooleanReason(true, "testing"); result = result.Invert(); Assert.IsFalse(result.Result, "After inversion result should be false"); Assert.IsTrue(result.Reason.Equals("testing", StringComparison.InvariantCulture), "After invert reason text should remain same."); }
public override BooleanReason Evaluate() { try { var installPath = GetInstallPath(); if (string.IsNullOrWhiteSpace(installPath)) return new BooleanReason(false, "Pgp install path not present in registry"); var utilityPath = Path.Combine(installPath, "pgpwde.exe"); if (!File.Exists(utilityPath)) return new BooleanReason(false, "Could not locate pgpwde.exe"); var diskNodes = GetDiskNodes(utilityPath); if (diskNodes == null || !diskNodes.Any()) return new BooleanReason(false, "Could not enumerate drives"); var result = new BooleanReason(true, "All fixed drives are encrypted."); foreach (var diskNode in diskNodes) { if (!IsRemovableDrive(diskNode)) continue; if (!IsDiskEncrypted(utilityPath, diskNode)) { Log.WarnFormat("Disk {0} ({1}) is fixed and not encrypted", GetDiskId(diskNode), GetDiskUuid(diskNode)); result = new BooleanReason(false, "Disk {0} ({1}) is fixed and not encrypted", GetDiskId(diskNode), GetDiskUuid(diskNode)); } } return result; } catch (Exception e) { Log.WarnFormat("An exception occurred while attempting to determine whether this computer's drives are encrypted with PGP Desktop encryption: {0}", e.Message); return new BooleanReason(e); } }