Ejemplo n.º 1
0
        public void GetFiles_WhenThereIsNoFiles_ReturnsEmpty()
        {
            //Arrange
            PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem);

            string path = Path.Combine(_userFolder, "Exist");

            _fileSystemMock
            .Setup(fs => fs.DirectoryExists(
                       It.Is <string>(s => s == path))
                   )
            .Returns(true);
            _fileSystemMock
            .Setup(
                fs => fs.GetFiles(
                    It.Is <string>(s => s == path), It.IsAny <string>(), It.IsAny <SearchOption>()
                    )
                )
            .Returns(new List <string>());

            //Act
            var result = creator.GetFiles(path, "FilterNotExists", SearchOption.TopDirectoryOnly);

            //Assert
            Assert.Empty(result);
            _fileSystemMock.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetFiles_WhenPathNotFound_ReturnsException()
        {
            //Arrange
            PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem);

            string path = Path.Combine(_userFolder, "NotExist");

            _fileSystemMock
            .Setup(fs => fs.DirectoryExists(
                       It.Is <string>(s => s == path))
                   )
            .Returns(false);

            //Act
            Action result = () => creator.GetFiles(path, null);

            //Assert
            Assert.Throws <DirectoryNotFoundException>(result);
            _fileSystemMock.VerifyAll();
        }
Ejemplo n.º 3
0
        public void GetFiles_WhenCalls_ReturnsFileList(string[] expectedResult, string path, string filter)
        {
            //Arrange
            PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem);

            path = Path.Combine(_userFolder, path);
            _fileSystemMock
            .Setup(fs => fs.DirectoryExists(
                       It.Is <string>(s => s == path))
                   )
            .Returns(true);
            _fileSystemMock
            .Setup(fs => fs.GetFiles(path, It.IsAny <string>(), It.IsAny <SearchOption>()))
            .Returns(expectedResult);

            //Act
            var result = creator.GetFiles(path, filter);

            //Assert
            Assert.Equal(expectedResult, result);
            _fileSystemMock.VerifyAll();
        }