Beispiel #1
0
        public void ChangeExtensionWithNull()
        {
            // Setup
            var file = new FsFile(@"x:\directory\File.txt");

            // Execute
            var result = file.ChangeExtension(a_extension: null);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public void ConstructFsFileWithNullPath()
 {
     // Execute
     var file = new FsFile(a_filePath: null);
 }
Beispiel #6
0
 public void ConstructFsFileWithBadPath()
 {
     // Execute
     var file = new FsFile("???");
 }
Beispiel #7
0
        /// <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;
        }