Пример #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
        private void ValidateActiveEnumeratorReturnsAllEntries(ActiveEnumeration activeEnumeration, IEnumerable <ProjectedFileInfo> entries)
        {
            activeEnumeration.IsCurrentValid.ShouldEqual(true);

            // activeEnumeration should iterate over each entry in entries
            foreach (ProjectedFileInfo entry in entries)
            {
                activeEnumeration.IsCurrentValid.ShouldEqual(true);
                activeEnumeration.Current.ShouldBeSameAs(entry);
                activeEnumeration.MoveNext();
            }

            // activeEnumeration should no longer be valid after iterating beyond the end of the list
            activeEnumeration.IsCurrentValid.ShouldEqual(false);

            // attempts to move beyond the end of the list should fail
            activeEnumeration.MoveNext().ShouldEqual(false);
        }
Пример #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 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);
        }