Ejemplo n.º 1
0
        public void CreateSymbolicLinkToLongPathFile()
        {
            using (var cleaner = new TestFileCleaner())
            {
                string filePath     = cleaner.CreateTestFile("CreateSymbolicLinkToLongPathFile");
                string symbolicLink = cleaner.GetTestPath();
                Action action       = () => NativeMethods.FileManagement.CreateSymbolicLink(symbolicLink, filePath);

                if (cleaner.ExtendedFileService.CanCreateSymbolicLinks())
                {
                    action();
                    var attributes = NativeMethods.FileManagement.GetFileAttributes(symbolicLink);
                    attributes.Should().HaveFlag(FileAttributes.ReparsePoint);
                }
                else
                {
                    action.ShouldThrow <IOException>().And.HResult.Should().Be(NativeErrorHelper.GetHResultForWindowsError(NativeMethods.WinError.ERROR_PRIVILEGE_NOT_HELD));
                }
            }
        }
Ejemplo n.º 2
0
 public void WindowsErrorTextIsAsExpected(int error, string expected)
 {
     NativeErrorHelper.LastErrorToString(error).Should().Be(expected);
 }