public void AlphaFS_Host_EnumerateOpenResources_Local_Success() { UnitTestAssert.IsElevatedProcess(); UnitTestConstants.PrintUnitTestHeader(false); var host = Environment.MachineName; Console.WriteLine("Connected to Host: [{0}]", host); var count = 0; foreach (var openResourceInfo in Alphaleonis.Win32.Network.Host.EnumerateOpenResources(host, null, null, false)) { UnitTestConstants.Dump(openResourceInfo); Assert.IsNotNull(openResourceInfo); count++; Console.WriteLine(); } if (count == 0) { UnitTestAssert.InconclusiveBecauseEnumerationIsEmpty(); } }
public void AlphaFS_File_SetTimestampsOnSymbolicLink_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); AlphaFS_File_SetTimestampsOnSymbolicLink(false); AlphaFS_File_SetTimestampsOnSymbolicLink(true); }
public void AlphaFS_Directory_Copy_SymbolicLink_SourceIsASymbolicLink_TargetMustAlsoBeASymbolicLink_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); AlphaFS_Directory_Copy_SymbolicLink_SourceIsASymbolicLink_TargetMustAlsoBeASymbolicLink(false); AlphaFS_Directory_Copy_SymbolicLink_SourceIsASymbolicLink_TargetMustAlsoBeASymbolicLink(true); }
public void File_SetAccessControl_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); File_SetAccessControl(false); File_SetAccessControl(true); }
public void AlphaFS_Directory_CreateSymbolicLink_And_GetLinkTargetInfo_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); AlphaFS_Directory_CreateSymbolicLink_And_GetLinkTargetInfo(false); AlphaFS_Directory_CreateSymbolicLink_And_GetLinkTargetInfo(true); }
public void File_Create_WithFileSecurity_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); File_Create_WithFileSecurity(false); File_Create_WithFileSecurity(true); }
public void AlphaFS_File_Move_DelayUntilReboot_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); AlphaFS_File_Move_DelayUntilReboot(false); AlphaFS_File_Move_DelayUntilReboot(true); }
public void AlphaFS_Directory_SetTimestamps_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); AlphaFS_Directory_SetTimestamps(false); AlphaFS_Directory_SetTimestamps(true); }
public void Directory_CreateDirectory_WithDirectorySecurity_LocalAndNetwork_Success() { UnitTestAssert.IsElevatedProcess(); Directory_CreateDirectory_WithDirectorySecurity(false); Directory_CreateDirectory_WithDirectorySecurity(true); }
public void AlphaFS_Volume_EnumerateVolumeMountPoints_Local_Success() { UnitTestAssert.IsElevatedProcess(); UnitTestConstants.PrintUnitTestHeader(false); var cnt = 0; Console.WriteLine("Logical Drives\n"); // Get Logical Drives from UnitTestConstants.Local Host, .IsReady Drives only. foreach (var drive in Alphaleonis.Win32.Filesystem.Directory.GetLogicalDrives(false, true)) { try { // Logical Drives --> Volumes --> Volume Mount Points. var uniqueVolName = Alphaleonis.Win32.Filesystem.Volume.GetUniqueVolumeNameForPath(drive); if (!Alphaleonis.Utils.IsNullOrWhiteSpace(uniqueVolName) && !uniqueVolName.Equals(drive, StringComparison.OrdinalIgnoreCase)) { foreach (var mountPoint in Alphaleonis.Win32.Filesystem.Volume.EnumerateVolumeMountPoints(uniqueVolName).Where(mp => !Alphaleonis.Utils.IsNullOrWhiteSpace(mp))) { string guid = null; try { guid = Alphaleonis.Win32.Filesystem.Volume.GetVolumeGuid(System.IO.Path.Combine(drive, mountPoint)); } catch (Exception ex) { Console.WriteLine("\n\tCaught (UNEXPECTED #1) {0}: [{1}]", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, " ")); } Console.WriteLine("\t#{0:000}\tLogical Drive: [{1}]\tGUID: [{2}]\n\t\tDestination : [{3}]\n", ++cnt, drive, guid ?? "null", mountPoint); } } } catch (Exception ex) { Console.WriteLine("\n\tCaught (UNEXPECTED #2) {0}: [{1}]", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, " ")); } } if (cnt == 0) { UnitTestAssert.InconclusiveBecauseResourcesAreUnavailable(); } }
public void AlphaFS_Host_EnumerateDrives_Network_Success() { UnitTestAssert.IsElevatedProcess(); UnitTestConstants.PrintUnitTestHeader(true); var host = Environment.MachineName; var drives = Alphaleonis.Win32.Network.Host.EnumerateDrives(host, true).ToArray(); foreach (var driveInfo in drives) { Console.WriteLine("Host Local Drive: [{0}]", driveInfo.Name); UnitTestConstants.Dump(driveInfo); UnitTestConstants.Dump(driveInfo.DiskSpaceInfo, true); UnitTestConstants.Dump(driveInfo.VolumeInfo, true); Assert.IsNull(driveInfo.DosDeviceName); Assert.IsNull(driveInfo.VolumeInfo.Guid); Console.WriteLine(); } if (drives.Length == 0) { UnitTestAssert.InconclusiveBecauseResourcesAreUnavailable(); } // \\localhost\C$ host = Alphaleonis.Win32.Network.Host.GetUncName() + Alphaleonis.Win32.Filesystem.Path.DirectorySeparator + UnitTestConstants.SysDrive[0] + Alphaleonis.Win32.Filesystem.Path.NetworkDriveSeparator + Alphaleonis.Win32.Filesystem.Path.DirectorySeparator; Assert.AreEqual(drives[0].Name, host); }
public void AlphaFS_Volume_SetVolumeMountPoint_And_DeleteVolumeMountPoint_Local_Success() { UnitTestAssert.IsElevatedProcess(); using (var tempRoot = new TemporaryDirectory()) { var folder = tempRoot.CreateDirectory(); Console.WriteLine("Input Directory Path: [{0}]", folder.FullName); var guid = Alphaleonis.Win32.Filesystem.Volume.GetVolumeGuid(UnitTestConstants.SysDrive); Console.WriteLine("\nCreate mount point."); Alphaleonis.Win32.Filesystem.Volume.SetVolumeMountPoint(folder.FullName, guid); Assert.IsTrue(Alphaleonis.Win32.Filesystem.Volume.EnumerateVolumeMountPoints(guid).Any(mountPoint => folder.FullName.EndsWith(mountPoint.TrimEnd('\\')))); var lvi = Alphaleonis.Win32.Filesystem.Directory.GetLinkTargetInfo(folder.FullName); UnitTestConstants.Dump(lvi, -14); Assert.IsTrue(lvi.SubstituteName.StartsWith(Alphaleonis.Win32.Filesystem.Path.NonInterpretedPathPrefix)); Assert.IsTrue(lvi.SubstituteName.EndsWith(guid.Replace(Alphaleonis.Win32.Filesystem.Path.LongPathPrefix, string.Empty))); Console.WriteLine("\nRemove mount point."); Alphaleonis.Win32.Filesystem.Volume.DeleteVolumeMountPoint(folder.FullName); Assert.IsFalse(Alphaleonis.Win32.Filesystem.Volume.EnumerateVolumeMountPoints(guid).Any(mountPoint => folder.FullName.EndsWith(mountPoint.TrimEnd('\\')))); } }
public void AlphaFS_DirectoryInfo_MoveTo_DelayUntilReboot_Local_Success() { UnitTestAssert.IsElevatedProcess(); AlphaFS_DirectoryInfo_MoveTo_DelayUntilReboot(false); }
public void AlphaFS_Volume_SetVolumeLabel_Local_Success() { UnitTestAssert.IsElevatedProcess(); UnitTestConstants.PrintUnitTestHeader(false); const string newLabel = "ÂĽpĥæƑŞ ŠëtVőlümèĻāßƩl() Ťest"; const string template = "System Drive: [{0}]\tCurrent Label: [{1}]\n"; var drive = UnitTestConstants.SysDrive; #region Get Label var originalLabel = Alphaleonis.Win32.Filesystem.Volume.GetVolumeLabel(drive); Console.WriteLine(template, drive, originalLabel); Assert.IsTrue(originalLabel.Equals(Alphaleonis.Win32.Filesystem.Volume.GetVolumeLabel(drive))); #endregion // Get Label #region Set Label var isLabelSet = false; var currentLabel = Alphaleonis.Win32.Filesystem.Volume.GetVolumeLabel(drive); try { Alphaleonis.Win32.Filesystem.Volume.SetVolumeLabel(drive, newLabel); isLabelSet = true; Console.WriteLine(template, drive, newLabel); Console.WriteLine("Set label."); Assert.IsTrue(!currentLabel.Equals(newLabel)); } catch (Exception ex) { Console.WriteLine("\nCaught (UNEXPECTED) {0}: [{1}]", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, " ")); } Assert.IsTrue(isLabelSet); #endregion // Set Label #region Remove Label var isLabelRemoved = false; try { Alphaleonis.Win32.Filesystem.Volume.DeleteVolumeLabel(drive); isLabelRemoved = true; currentLabel = Alphaleonis.Win32.Filesystem.Volume.GetVolumeLabel(drive); Console.WriteLine(template, drive, currentLabel); Console.WriteLine("Removed label."); Assert.IsTrue(currentLabel.Equals(string.Empty)); } catch (Exception ex) { Console.WriteLine("\nCaught (UNEXPECTED) {0}: [{1}]", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, " ")); } Assert.IsTrue(isLabelRemoved); #endregion // Remove Label #region Restore Label isLabelSet = false; try { Alphaleonis.Win32.Filesystem.Volume.SetVolumeLabel(drive, originalLabel); isLabelSet = true; currentLabel = Alphaleonis.Win32.Filesystem.Volume.GetVolumeLabel(drive); Console.WriteLine(template, drive, currentLabel); Console.WriteLine("Restored label."); Assert.IsTrue(currentLabel.Equals(originalLabel)); } catch (Exception ex) { Console.WriteLine("\nCaught (UNEXPECTED) {0}: [{1}]", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, " ")); } Assert.IsTrue(isLabelSet); #endregion // Restore Label }