public void PathAlreadyExistsAsDirectory() { string path = GetTestFilePath(); DirectoryInfo testDir = Directory.CreateDirectory(path); Assert.True(Exists(IOServices.RemoveTrailingSlash(path))); Assert.True(Exists(IOServices.RemoveTrailingSlash(IOServices.RemoveTrailingSlash(path)))); Assert.True(Exists(IOServices.RemoveTrailingSlash(IOServices.AddTrailingSlashIfNeeded(path)))); }
public void DotDotIsParentDirectory() { DirectoryInfo result = new DirectoryInfo(TestDirectory).CreateSubdirectory(Path.Combine(GetTestFileName(), "..")); Assert.Equal(IOServices.RemoveTrailingSlash(TestDirectory), result.FullName); result = new DirectoryInfo(TestDirectory).CreateSubdirectory(Path.Combine(GetTestFileName(), "..") + Path.DirectorySeparatorChar); Assert.Equal(IOServices.AddTrailingSlashIfNeeded(TestDirectory), result.FullName); }
public void DotIsCurrentDirectory() { string path = GetTestFilePath(); DirectoryInfo result = Create(Path.Combine(path, ".")); Assert.Equal(IOServices.RemoveTrailingSlash(path), result.FullName); result = Create(Path.Combine(path, ".") + Path.DirectorySeparatorChar); Assert.Equal(IOServices.AddTrailingSlashIfNeeded(path), result.FullName); }
[PlatformSpecific(TestPlatforms.Windows)] // Extended path already exists as directory public void ExtendedPathAlreadyExistsAsDirectory() { string path = IOInputs.ExtendedPrefix + GetTestFilePath(); Directory.CreateDirectory(path); Assert.True(Exists(IOServices.RemoveTrailingSlash(path))); Assert.True(Exists(IOServices.RemoveTrailingSlash(IOServices.RemoveTrailingSlash(path)))); Assert.True(Exists(IOServices.RemoveTrailingSlash(IOServices.AddTrailingSlashIfNeeded(path)))); }
public void PathAlreadyExistsAsFile() { string path = GetTestFilePath(); File.Create(path).Dispose(); Assert.True(Exists(IOServices.RemoveTrailingSlash(path))); Assert.True(Exists(IOServices.RemoveTrailingSlash(IOServices.RemoveTrailingSlash(path)))); Assert.True(Exists(IOServices.RemoveTrailingSlash(IOServices.AddTrailingSlashIfNeeded(path)))); }
public void PathAlreadyExistsAsFile() { string path = GetTestFilePath(); File.Create(path).Dispose(); Assert.Throws <IOException>(() => Create(path)); Assert.Throws <IOException>(() => Create(IOServices.AddTrailingSlashIfNeeded(path))); Assert.Throws <IOException>(() => Create(IOServices.RemoveTrailingSlash(path))); }
[PlatformSpecific(TestPlatforms.Windows)] // trailing slash public void ValidExtendedPathWithTrailingSlash(string component) { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); string path = IOInputs.ExtendedPrefix + IOServices.AddTrailingSlashIfNeeded(Path.Combine(testDir.FullName, component)); DirectoryInfo result = Create(path); Assert.Equal(path, result.FullName); Assert.True(result.Exists); }
[PlatformSpecific(TestPlatforms.Windows)] // Extended path already exists as file public void ExtendedPathAlreadyExistsAsFile() { string path = IOInputs.ExtendedPrefix + GetTestFilePath(); File.Create(path).Dispose(); Assert.False(Exists(IOServices.RemoveTrailingSlash(path))); Assert.False(Exists(IOServices.RemoveTrailingSlash(IOServices.RemoveTrailingSlash(path)))); Assert.False(Exists(IOServices.RemoveTrailingSlash(IOServices.AddTrailingSlashIfNeeded(path)))); }
public void ValidPathWithTrailingSlash(string component) { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); string path = IOServices.AddTrailingSlashIfNeeded(component); DirectoryInfo result = new DirectoryInfo(testDir.FullName).CreateSubdirectory(path); Assert.Equal(Path.Combine(testDir.FullName, path), result.FullName); Assert.True(Directory.Exists(result.FullName)); }
public static void Exists_ExistingDirectoryWithTrailingSlashAsPath_ReturnsTrue() { using (TemporaryDirectory directory = new TemporaryDirectory()) { string path = IOServices.AddTrailingSlashIfNeeded(directory.Path); bool result = Directory.Exists(path); Assert.True(result); } }
public static void Exists_FileWithTrailingSlashAsPath_ReturnsFalse() { using (TemporaryFile file = new TemporaryFile()) { string path = IOServices.AddTrailingSlashIfNeeded(file.Path); bool result = Directory.Exists(path); Assert.False(result); } }
public static void CreateDirectory_FileWithTrailingSlashAsPath_ThrowsIOException() { using (TemporaryFile file = new TemporaryFile()) { string path = IOServices.AddTrailingSlashIfNeeded(file.Path); Assert.Throws <IOException>(() => { Directory.CreateDirectory(path); }); } }
public static void CreateDirectory_ExistingDirectoryWithTrailingSlashAsPath_DoesNotThrow() { using (TemporaryDirectory directory = new TemporaryDirectory()) { string path = IOServices.AddTrailingSlashIfNeeded(directory.Path); DirectoryInfo result = Directory.CreateDirectory(path); Assert.Equal(path, result.FullName); Assert.True(Directory.Exists(result.FullName)); } }
public void ValidPathWithTrailingSlash() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); var components = IOInputs.GetValidPathComponentNames(); Assert.All(components, (component) => { string path = IOServices.AddTrailingSlashIfNeeded(Path.Combine(testDir.FullName, component)); DirectoryInfo result = Create(path); Assert.Equal(path, result.FullName); Assert.True(result.Exists); }); }
public static void CreateDirectory_ValidPathWithTrailingSlash_CanBeCreated() { using (TemporaryDirectory directory = new TemporaryDirectory()) { var components = IOInputs.GetValidPathComponentNames(); foreach (var component in components) { string path = IOServices.AddTrailingSlashIfNeeded(Path.Combine(directory.Path, component)); DirectoryInfo result = Directory.CreateDirectory(path); Assert.Equal(path, result.FullName); Assert.True(Directory.Exists(result.FullName)); } } }
public void NonExistentFile() { Assert.Throws <FileNotFoundException>(() => Set(GetTestFilePath(), FileAttributes.Normal)); Assert.Throws <FileNotFoundException>(() => Set(IOServices.AddTrailingSlashIfNeeded(GetTestFilePath()), FileAttributes.Normal)); Assert.Throws <FileNotFoundException>(() => Set(IOServices.RemoveTrailingSlash(GetTestFilePath()), FileAttributes.Normal)); }
public void PathAlreadyExistsAsFile() { string path = GetTestFileName(); File.Create(Path.Combine(TestDirectory, path)).Dispose(); Assert.Throws <IOException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(path)); Assert.Throws <IOException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(IOServices.AddTrailingSlashIfNeeded(path))); Assert.Throws <IOException>(() => new DirectoryInfo(TestDirectory).CreateSubdirectory(IOServices.RemoveTrailingSlash(path))); }