Beispiel #1
0
        public void OpenTest()
        {
            //Arrange
            FileSystemExplorer target = new FileSystemExplorer();
            String[] drivers = GetValidDrives();

            //Act
            target.Open(String.Format("{0}:\\", drivers[0]));

            //Assert
            Assert.IsTrue(target.CurrentPath.StartsWith(drivers[0]));
        }
Beispiel #2
0
        public void ConstructorTest()
        {
            //Arrange
            String[] expected = GetValidDrives();

            //Act
            FileSystemExplorer target = new FileSystemExplorer();

            //Assert
            IEnumerable<Element> actual = target.GetCurrentContents();
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Length, actual.Count());
            for (int i = 0; i < expected.Length; ++i)
            {
                Assert.AreEqual(String.Format("{0}:\\", expected[i]), actual.Take(i + 1).Last().FullPath);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            IExplorer explorer = new FileSystemExplorer();
            IEnumerable<Element> contents = null;

            Console.WriteLine(explorer.CurrentPath ?? "<nothing>");
            contents = explorer.GetCurrentContents();

            PrintCurrentContents(contents);

            explorer.Open("D:\\");
            Console.WriteLine(explorer.CurrentPath ?? "<nothing>");

            contents = explorer.GetCurrentContents();

            PrintCurrentContents(contents);

            explorer.Open("Btuga downloads");

            contents = explorer.GetCurrentContents();

            PrintCurrentContents(contents);

            //DriveInfo[] drives = DriveInfo.GetDrives();
            //foreach (DriveInfo di in drives.Where(d => d.IsReady))
            //{
            //    Console.WriteLine("{0}", di.Name);
            //    //foreach(var fsi in di.RootDirectory.GetFileSystemInfos()){
            //    //    Console.WriteLine("     {0}", fsi.Name);
            //    //}

            //    Console.WriteLine(di.RootDirectory.Parent == null ? "No parent" : di.RootDirectory.Parent.Name);
            //    foreach (var fsi in di.RootDirectory.GetDirectories())
            //    {
            //        Console.WriteLine("     {0}", fsi.Name);
            //    }
            //    foreach (var fsi in di.RootDirectory.GetFiles())
            //    {
            //        Console.WriteLine("     {0}", fsi.Name);
            //    }
            //}
        }
Beispiel #4
0
        public void UpTest()
        {
            //Arrange
            FileSystemExplorer target = new FileSystemExplorer();
            String[] drivers = GetValidDrives();
            target.Open(String.Format("{0}:\\", drivers[0]));

            //Act
            target.Up();

            //Assert
            Assert.AreEqual(String.Empty, target.CurrentPath);
        }