Example #1
0
        public void ShouldEnumerateAllFilesInADirectoryRecursively()
        {
            _sut = new FileEnumerator();
            _sut.Paths.Add(new PathSearchInfo(_testRoot, SearchOption.AllDirectories));

            FileInfo[] list = _sut.ToArray();

            list.Length.Should().Be(5 + (5 * 5));
        }
Example #2
0
        public void ShouldNotReturnDuplicatedItems()
        {
            _sut = new FileEnumerator();
            _sut.Paths.Add(new PathSearchInfo(_testRoot, "3.test", SearchOption.AllDirectories));
            _sut.Paths.Add(new PathSearchInfo(Path.Combine(_testRoot, "4")));

            FileInfo[] list = _sut.ToArray();

            list.Length.Should().Be((1 + 5) + (5) - 1);
        }
Example #3
0
        public void ShouldEnumerateFilesFromMultiplePaths()
        {
            _sut = new FileEnumerator();
            _sut.Paths.Add(new PathSearchInfo(Path.Combine(_testRoot, "2")));
            _sut.Paths.Add(new PathSearchInfo(Path.Combine(_testRoot, "4")));

            FileInfo[] list = _sut.ToArray();

            list.Length.Should().Be(2 * 5);
        }
Example #4
0
        public void ShouldEnumerateAllFilesMatchingAFilter()
        {
            _sut = new FileEnumerator();
            _sut.Paths.Add(new PathSearchInfo(_testRoot, "3.*", SearchOption.AllDirectories));

            FileInfo[] list = _sut.ToArray();

            list.Length.Should().Be(1 + (5));
            list.Select(x => x.Name).All(x => x.StartsWith("3.")).Should().Be.True();
        }
Example #5
0
        public void ShouldEnumerateAllFilesInADirectory()
        {
            _sut = new FileEnumerator();
            _sut.Paths.Add(new PathSearchInfo(_testRoot));

            FileInfo[] list = _sut.ToArray();

            list.Length.Should().Be(5);
            list.Select(x => x.Name)
            .Should()
            .Have.SameValuesAs(new[] { "1.test", "2.test", "3.test", "4.test", "5.test" });
        }