Ejemplo n.º 1
0
        public void DirectoryConstructorWithoutParametersTest()
        {
            //Arrange

            //Act
            Directory target = new Directory();

            //Assert
            Assert.IsNotNull(target.Children);
        }
Ejemplo n.º 2
0
        public void DirectoryConstructorWithDirectoryInfoTest()
        {
            //Arrange
            DirectoryInfo info = new DirectoryInfo((string)(TestContext.Properties[ValidFolderPathKey]));

            //Act
            Directory target = new Directory(info.Name, info.FullName, null);

            //Assert
            Assert.IsNotNull(target.Children);
            Assert.AreEqual(target.Name, info.Name);
            Assert.AreEqual(target.FullPath, info.FullName);
        }
Ejemplo n.º 3
0
        public void Open(String name)
        {
            if (_current == null)
            {
                _current = (from di in _fileStruture
                            where di.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase)
                            select di).FirstOrDefault();
                if (_current == null)
                    throw new DirectoryNotFoundException("Invalid path");

                CurrentPath = _current.FullPath;
                return;
            }

            Directory next = _current.Children.Where(dir => dir.Name.Equals(name)).FirstOrDefault() as Directory;

            if (next == null)
                throw new DirectoryNotFoundException("Invalid directory");

            _current = next;
            CurrentPath = next.FullPath;
        }
Ejemplo n.º 4
0
        public void Up()
        {
            if(_current == null){
                return;
            }

            _current = _current.Parent;
            CurrentPath = _current != null ? _current.FullPath : String.Empty;
        }
Ejemplo n.º 5
0
 public File(String name, String fullPath, Directory parent)
     : base(name, fullPath)
 {
     Parent = parent;
 }