Ejemplo n.º 1
0
        public void CreateModel_ValidDirectoryPath_ReturnsStatusModel()
        {
            // Arrange
            const string directoryPath    = "directoryPath";
            const string directoryName    = "directory";
            const string subDirectoryName = "subdirectory";
            const string fileName         = "file";
            string       fileFullPath     = System.IO.Path.Combine(directoryName, subDirectoryName, fileName);
            var          rootNode         = new Directory {
                Name = directoryName
            };
            var childDirectory = new Directory {
                Name = subDirectoryName, Parent = rootNode
            };
            var childFile = new File {
                Name = fileName, Parent = childDirectory
            };

            var files = new List <INode> {
                childFile
            };

            // Act
            var result = FileStatusModelBuilder.CreateModel(directoryPath, files);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Files.Count);
            Assert.AreEqual(fileName, result.Files[0].Name);
            Assert.IsTrue(result.Files[0].IsFile);
            Assert.AreEqual(fileFullPath, result.Files[0].FullPath);
        }
Ejemplo n.º 2
0
        public IActionResult Index(string path)
        {
            var files = _fileSystem.GetListing(path);

            return(View(FileStatusModelBuilder.CreateModel(path, files)));
        }