public void LocalPathTests() { char testDriveLetter = 'c'; string pathUnderTest = string.Format(@"{0}:\plop", testDriveLetter); AfsPath path = new AfsPath(pathUnderTest); Assert.True(path.Length == pathUnderTest.Length, "invalid path length"); Assert.True(path.DriveLetter.HasValue && path.DriveLetter.Value == testDriveLetter, $"{nameof(path.DriveLetter)} should be set to {testDriveLetter}"); Assert.True(path.ComputerName == null, $"{nameof(path.ComputerName)} should not be set"); Assert.True(path.ShareName == null, $"{nameof(path.ShareName)} should not be set"); }
private IValidationResult ValidateInternal(INamedObjectInfo node) { AfsPath path = new AfsPath(node.FullName); int depth = path.Depth; bool isTooDeep = depth > this._maxTreeDepth; if (isTooDeep) { return(new ValidationResult { Result = Result.Fail, Description = $"Directory tree depth limit exceeded. Maximum tree depth is {this._maxTreeDepth}.", Level = ResultLevel.Error, Path = node.FullName, Type = this.ValidationType }); } return(this.SuccessfulResult); }
public void UncPathWithDriveTests() { string testPath = @"data"; string testComputerName = "some-computer-name"; char testDriveLetter = 'c'; var pathUnderTest = Path.Combine($@"\\{testComputerName}", $"{testDriveLetter}$", testPath); AfsPath path = new AfsPath(pathUnderTest); Assert.True(path.Length == testPath.Length + 3, "invalid path length"); Assert.True(path.Depth == 1, "invalid depth"); Assert.True(path.DriveLetter.HasValue && path.DriveLetter.Value == testDriveLetter, $"{nameof(path.DriveLetter)} should be set to {testDriveLetter}"); Assert.True(path.ShareName == null, $"{nameof(path.ShareName)} should not be set"); Assert.True(path.ComputerName == testComputerName, $"{nameof(path.ComputerName)} should be set to {testComputerName}"); }
private IValidationResult ValidateInternal(INamedObjectInfo node) { AfsPath path = new AfsPath(node.FullName); int pathLength = path.Length; bool pathIsTooLong = pathLength > this._maxPathLength; if (pathIsTooLong) { return(new ValidationResult { Result = Result.Fail, Description = $"Path length limit exceeded. Maximum length is {this._maxPathLength}.", Level = ResultLevel.Error, Path = node.FullName, Type = this.ValidationType }); } return(this.SuccessfulResult); }