Пример #1
0
        public void EnumerateSingleEntryListWithWildcardFilter()
        {
            List <ProjectedFileInfo> entries = new List <ProjectedFileInfo>()
            {
                new ProjectedFileInfo("a", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 1))
            };

            using (ActiveEnumeration activeEnumeration = new ActiveEnumeration(entries))
            {
                activeEnumeration.TrySaveFilterString("*").ShouldEqual(true);
                this.ValidateActiveEnumeratorReturnsAllEntries(activeEnumeration, entries);
            }

            using (ActiveEnumeration activeEnumeration = new ActiveEnumeration(entries))
            {
                activeEnumeration.TrySaveFilterString("?").ShouldEqual(true);
                this.ValidateActiveEnumeratorReturnsAllEntries(activeEnumeration, entries);
            }

            using (ActiveEnumeration activeEnumeration = new ActiveEnumeration(entries))
            {
                string filter = "*.*";
                activeEnumeration.TrySaveFilterString(filter).ShouldEqual(true);

                // "*.*" should only match when there is a . in the name
                activeEnumeration.IsCurrentValid.ShouldEqual(false);
                activeEnumeration.MoveNext().ShouldEqual(false);
                activeEnumeration.RestartEnumeration(filter);
                activeEnumeration.IsCurrentValid.ShouldEqual(false);
            }
        }
Пример #2
0
        public void RestartingScanWithFilterAdvancesEnumeratorToNewMatchingEntry()
        {
            List <ProjectedFileInfo> entries = new List <ProjectedFileInfo>()
            {
                new ProjectedFileInfo("a", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 1)),
                new ProjectedFileInfo("B", size: 0, isFolder: true, sha: Sha1Id.None),
                new ProjectedFileInfo("c", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 2)),
                new ProjectedFileInfo("D.txt", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 3)),
                new ProjectedFileInfo("E.txt", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 4)),
                new ProjectedFileInfo("E.bat", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 5)),
            };

            using (ActiveEnumeration activeEnumeration = new ActiveEnumeration(entries))
            {
                activeEnumeration.IsCurrentValid.ShouldEqual(true);
                activeEnumeration.Current.ShouldBeSameAs(entries[0]);
                activeEnumeration.TrySaveFilterString("D.txt").ShouldEqual(true);
                activeEnumeration.IsCurrentValid.ShouldEqual(true);
                activeEnumeration.Current.Name.ShouldEqual("D.txt");

                activeEnumeration.RestartEnumeration("c");
                activeEnumeration.IsCurrentValid.ShouldEqual(true);
                activeEnumeration.Current.Name.ShouldEqual("c");
            }
        }
Пример #3
0
 public void EnumerationHandlesEmptyList()
 {
     using (ActiveEnumeration activeEnumeration = new ActiveEnumeration(new List <ProjectedFileInfo>()))
     {
         activeEnumeration.IsCurrentValid.ShouldEqual(false);
         activeEnumeration.MoveNext().ShouldEqual(false);
         activeEnumeration.RestartEnumeration(string.Empty);
         activeEnumeration.IsCurrentValid.ShouldEqual(false);
     }
 }
        public void EnumerationHandlesEmptyList()
        {
            ActiveEnumeration activeEnumeration = CreateActiveEnumeration(new List <ProjectedFileInfo>());

            activeEnumeration.MoveNext().ShouldEqual(false);
            activeEnumeration.Current.ShouldEqual(null);

            activeEnumeration.RestartEnumeration(string.Empty);
            activeEnumeration.IsCurrentValid.ShouldEqual(false);
            activeEnumeration.Current.ShouldEqual(null);
        }
Пример #5
0
        public void EnumerateSingleEntryListWithNonMatchingFilter()
        {
            List <ProjectedFileInfo> entries = new List <ProjectedFileInfo>()
            {
                new ProjectedFileInfo("a", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 1))
            };

            using (ActiveEnumeration activeEnumeration = new ActiveEnumeration(entries))
            {
                string filter = "b";
                activeEnumeration.TrySaveFilterString(filter).ShouldEqual(true);
                activeEnumeration.IsCurrentValid.ShouldEqual(false);
                activeEnumeration.MoveNext().ShouldEqual(false);
                activeEnumeration.RestartEnumeration(filter);
                activeEnumeration.IsCurrentValid.ShouldEqual(false);
            }
        }
        public void RestartingScanWithFilterAdvancesEnumeratorToFirstMatchingEntry()
        {
            List <ProjectedFileInfo> entries = new List <ProjectedFileInfo>()
            {
                new ProjectedFileInfo("C.TXT", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 1)),
                new ProjectedFileInfo("D.txt", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 2)),
                new ProjectedFileInfo("E.txt", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 3)),
                new ProjectedFileInfo("E.bat", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 4)),
            };

            ActiveEnumeration activeEnumeration = CreateActiveEnumeration(entries);

            activeEnumeration.TrySaveFilterString("D.txt").ShouldEqual(true);
            activeEnumeration.IsCurrentValid.ShouldEqual(true);
            activeEnumeration.Current.Name.ShouldEqual("D.txt");

            activeEnumeration.RestartEnumeration("c*");
            activeEnumeration.IsCurrentValid.ShouldEqual(true);
            activeEnumeration.Current.Name.ShouldEqual("C.TXT");
        }
        public void EnumerateMultipleEntryListWithNonMatchingFilter()
        {
            List <ProjectedFileInfo> entries = new List <ProjectedFileInfo>()
            {
                new ProjectedFileInfo("a", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 1)),
                new ProjectedFileInfo("B", size: 0, isFolder: true, sha: Sha1Id.None),
                new ProjectedFileInfo("c", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 2)),
                new ProjectedFileInfo("D.txt", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 3)),
                new ProjectedFileInfo("E.txt", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 4)),
                new ProjectedFileInfo("E.bat", size: 0, isFolder: false, sha: new Sha1Id(1, 1, 5)),
            };

            ActiveEnumeration activeEnumeration = CreateActiveEnumeration(entries);
            string            filter            = "g";

            activeEnumeration.TrySaveFilterString(filter).ShouldEqual(true);
            activeEnumeration.IsCurrentValid.ShouldEqual(false);
            activeEnumeration.MoveNext().ShouldEqual(false);
            activeEnumeration.RestartEnumeration(filter);
            activeEnumeration.IsCurrentValid.ShouldEqual(false);
        }