Exemplo n.º 1
0
        //public static bool AreTreesSame(RootEntry re1, RootEntry re2)
        //{
        //    LastMessage = "";
        //    var differenceFound = false;
        //    var e1 = new DirEntryEnumerator(re1);
        //    var e2 = new DirEntryEnumerator(re2);

        //    while (e1.MoveNext() && e2.MoveNext())
        //    {
        //        LastMessage = string.Format("{0} not same as {1}", e1.Current.Name, e2.Current.Name);
        //        if (e1.Current.Name != e2.Current.Name)
        //        {
        //            differenceFound = true;
        //            break;
        //        }
        //        Console.WriteLine(LastMessage);
        //    }
        //    var bothTreesComplete = e1.MoveNext() == false && e2.MoveNext() == false;
        //    return !differenceFound && bothTreesComplete;
        //}

        public static bool SameTree(this RootEntry re1, RootEntry re2)
        {
            LastMessage = "";

            if (re1.Path != re2.Path)
            {
                LastMessage = $"RootPath {re1.Path} not same as {re2.Path}";
                return(false);
            }

            var differenceFound = false;
            var e1 = new DirEntryEnumerator(re1);
            var e2 = new DirEntryEnumerator(re2);

            while (e1.MoveNext() && e2.MoveNext())
            {
                LastMessage = $"{e1.Current.Path} not same as {e2.Current.Path}";
                if (e1.Current.Path != e2.Current.Path)
                {
                    differenceFound = true;
                    break;
                }
                Console.WriteLine(LastMessage);
            }
            var bothTreesComplete = e1.MoveNext() == false && e2.MoveNext() == false;

            return(!differenceFound && bothTreesComplete);
        }
Exemplo n.º 2
0
        public void MoveNext_WithTree_AfterMoveNextCurrentHasFirstEntry()
        {
            var e = new DirEntryEnumerator(RootEntries);

            e.MoveNext();

            Assert.That(e.Current, Is.EqualTo(De1), "Did not get de1 entry.");
        }
Exemplo n.º 3
0
        public void MoveNext_WithTree_AfterTwoMoveNextCurrentHasSecondEntry()
        {
            var e = new DirEntryEnumerator(RootEntries);

            e.MoveNext();
            e.MoveNext();

            Assert.That(e.Current, Is.EqualTo(Fe2), "Did not get fe2 entry.");
        }
Exemplo n.º 4
0
        public void MoveNext_NoRootEntries_FirstMoveNextFalse()
        {
            RootEntries = new List <RootEntry>();

            var e = new DirEntryEnumerator(RootEntries);

            Assert.That(e.Current, Is.Null);
            Assert.That(e.MoveNext(), Is.False);
        }
Exemplo n.º 5
0
        public void MoveNext_WithTree_ThirdMoveNextReturnsFalse()
        {
            var e = new DirEntryEnumerator(RootEntries);

            e.MoveNext();
            e.MoveNext();

            Assert.That(e.MoveNext(), Is.False, "There are only supposed to be 2 entries");
        }
Exemplo n.º 6
0
        public void ListOfRootEntryTest_TryOutEnumerable()
        {
            var fe3 = new DirEntry {
                Path = "fe3"
            };

            De1.Children.Add(fe3);
            var myListEnumerator = new DirEntryEnumerator(RootEntries);

            var expectList = new List <DirEntry> {
                De1, Fe2, fe3
            };
            var expectEnumerator = expectList.GetEnumerator();

            while (myListEnumerator.MoveNext() && expectEnumerator.MoveNext())
            {
                Console.WriteLine($"a {myListEnumerator.Current.Path}");
                if (expectEnumerator.Current != null)
                {
                    Console.WriteLine($"b {expectEnumerator.Current.Path}");
                    Assert.That(myListEnumerator.Current, Is.EqualTo(expectEnumerator.Current), "Sequence of directory entries is not matching.");
                }
            }
        }
Exemplo n.º 7
0
        public void MoveNext_WithTree_FirstMoveNextIsTrue()
        {
            var e = new DirEntryEnumerator(RootEntries);

            Assert.That(e.MoveNext(), Is.True);
        }
Exemplo n.º 8
0
        public void MoveNext_WithTree_CurrentIsNullBeforeMoveNext()
        {
            var e = new DirEntryEnumerator(RootEntries);

            Assert.That(e.Current, Is.Null);
        }