public void ChangeExtensionWithNull() { // Setup var file = new FsFile(@"x:\directory\File.txt"); // Execute var result = file.ChangeExtension(a_extension: null); }
public void ConstructFsFile() { // Execute var file = new FsFile(@"x:\directory\File.txt"); // Assert Assert.AreEqual("File.txt", file.Name); Assert.AreEqual(@"x:\directory\File.txt", file.Path); }
public void ChangeExtension() { // Setup var file = new FsFile(@"x:\directory\File.txt"); // Execute var result = file.ChangeExtension("jpg"); Assert.AreEqual("File.jpg", result.Name); Assert.AreEqual(@"x:\directory\File.jpg", result.Path); }
public void GetDirectory() { // Setup var file = new FsFile(@"x:\directory\File.txt"); // Execute var result = file.Directory; // Assert Assert.AreEqual("directory", result.Name); Assert.AreEqual(@"x:\directory", result.Path); }
public void ConstructFsFileWithNullPath() { // Execute var file = new FsFile(a_filePath: null); }
public void ConstructFsFileWithBadPath() { // Execute var file = new FsFile("???"); }
/// <summary> /// Copy the given file (<paramref name="a_file"/>) into this directory keeping the file name the same overwrite if necessary. /// </summary> /// <param name="a_file">File to copy.</param> public IFile CopyIn(IFile a_file) { #region Argument Validation if (a_file == null) throw new ArgumentNullException(nameof(a_file)); #endregion if (!a_file.Exists) throw new FileNotFoundException($"File at path \"{a_file.Path}\" does not exist."); if (!Exists) throw new DirectoryNotFoundException($"Directory at path \"{Path}\" does not exist."); var newPath = Path.Child(a_file.Name); var file = new FsFile(newPath); file.CopyFrom(a_file); return file; }