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

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