Esempio n. 1
0
        public void TestMethodTreeTwoPlusOneDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            root.AddDirectory("c:\\test\\test2");
            ClassDirectory test3 = root.AddDirectory("c:\\test\\test3");

            test3.AddDirectory("c:\\test\\test3\\test4");

            int cpt = 0;
            foreach (var item in root)
            {
                Assert.AreEqual(item.Type, "Dir.");
                Assert.AreEqual(item.Size, 0);
                foreach (var itm in (ClassDirectory) item)
                {
                    Assert.AreEqual(itm.Type, "Dir.");
                    Assert.AreEqual(itm.Size, 0);
                    cpt++;
                }
                cpt++;
            }

            Assert.AreEqual(cpt, 3);
        }
Esempio n. 2
0
        public void TestMethodTreeTwoPlusOneDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            root.AddDirectory("c:\\test\\test2");
            ClassDirectory test3 = root.AddDirectory("c:\\test\\test3");

            test3.AddDirectory("c:\\test\\test3\\test4");

            int cpt = 0;

            foreach (var item in root)
            {
                Assert.AreEqual(item.Type, "Dir.");
                Assert.AreEqual(item.Size, 0);
                foreach (var itm in (ClassDirectory)item)
                {
                    Assert.AreEqual(itm.Type, "Dir.");
                    Assert.AreEqual(itm.Size, 0);
                    cpt++;
                }
                cpt++;
            }

            Assert.AreEqual(cpt, 3);
        }
Esempio n. 3
0
        public void TestMethodTreeTwoDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            root.AddDirectory("c:\\test\\test2");
            root.AddDirectory("c:\\test\\test3");

            int cpt = 0;
            foreach (var item in root)
            {
                Assert.AreEqual(item.Type, "Dir.");
                Assert.AreEqual(item.Size, 0);
                cpt++;
            }

            Assert.AreEqual(cpt, 2);
        }
Esempio n. 4
0
        public void TestMethodTreeTwoDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            root.AddDirectory("c:\\test\\test2");
            root.AddDirectory("c:\\test\\test3");

            int cpt = 0;

            foreach (var item in root)
            {
                Assert.AreEqual(item.Type, "Dir.");
                Assert.AreEqual(item.Size, 0);
                cpt++;
            }

            Assert.AreEqual(cpt, 2);
        }
Esempio n. 5
0
        public void TestMethodSizeMultipleFileMultipleDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            ClassDirectory test1 = root.AddDirectory("c:\\test\\test1");
            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");

            ClassDirectory test3 = test2.AddDirectory("c:\\test\\test2\\test3");

            ClassFile file1 = test3.AddFile("c:\\test\\test2\\test3\\file1", 80, "123");

            ClassFile file2 = test3.AddFile("c:\\test\\test2\\test3\\file2", 60, "123");
            ClassFile file3 = test3.AddFile("c:\\test\\test2\\test3\\file3", 10, "123");

            ClassFile file4 = test1.AddFile("c:\\test\\test1\\file4", 30, "123");
            ClassFile file5 = test2.AddFile("c:\\test\\test1\\file5", 50, "123");

            Assert.AreEqual(root.Size, file1.Size + file2.Size + file3.Size + file4.Size + file5.Size);
        }
Esempio n. 6
0
        public void TestMethodSizeMultipleFileMultipleDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            ClassDirectory test1 = root.AddDirectory("c:\\test\\test1");
            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");

            ClassDirectory test3 = test2.AddDirectory("c:\\test\\test2\\test3");

            ClassFile file1 = test3.AddFile("c:\\test\\test2\\test3\\file1", 80, "123");

            ClassFile file2 = test3.AddFile("c:\\test\\test2\\test3\\file2", 60, "123");
            ClassFile file3 = test3.AddFile("c:\\test\\test2\\test3\\file3", 10, "123");

            ClassFile file4 = test1.AddFile("c:\\test\\test1\\file4", 30, "123");
            ClassFile file5 = test2.AddFile("c:\\test\\test1\\file5", 50, "123");

            Assert.AreEqual(root.Size, file1.Size + file2.Size + file3.Size + file4.Size + file5.Size);
        }
Esempio n. 7
0
        public void TestMethodSizeTwoFileOneDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");


            ClassFile file1 = test2.AddFile("c:\\test\\test2\\file1", 80, "123");
            ClassFile file2 = test2.AddFile("c:\\test\\test2\\file2", 60, "123");

            Assert.AreEqual(root.Size, file1.Size + file2.Size);
        }
Esempio n. 8
0
        public void TestMethodSizeOneFileTwoDir()
        {
            ClassDirectory root=new ClassDirectory("c:\\test");

            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");

            ClassDirectory test3 = test2.AddDirectory("c:\\test\\test2\\test3");

            ClassFile file1 = test3.AddFile("c:\\test\\test2\\test3\\file1", 80, "123");

            Assert.AreEqual(root.Size,file1.Size);
        }
Esempio n. 9
0
        public void TestMethodDuplicateTwoFileSameMd5()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");

            ClassFile file1 = test2.AddFile("c:\\test\\test2\\file1", 80, "123");
            ClassFile file2 = test2.AddFile("c:\\test\\test2\\file2", 60, "123");

            Assert.AreEqual(1, file1.NbDuplicate);
            Assert.AreEqual(1, file2.NbDuplicate);
        }
Esempio n. 10
0
        public void TestMethodDuplicateMultipleFileMultipleMd5()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            ClassDirectory test1 = root.AddDirectory("c:\\test\\test1");
            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");

            ClassDirectory test3 = test2.AddDirectory("c:\\test\\test2\\test3");

            ClassFile file1 = test3.AddFile("c:\\test\\test2\\test3\\file1", 80, "123");

            test3.AddFile("c:\\test\\test2\\test3\\file2", 60, "123");
            ClassFile file3 = test3.AddFile("c:\\test\\test2\\test3\\file3", 10, "789");

            test1.AddFile("c:\\test\\test1\\file4", 30, "456");
            ClassFile file5 = test2.AddFile("c:\\test\\test1\\file5", 50, "123");

            Assert.AreEqual(2, file1.NbDuplicate);
            Assert.AreEqual(0, file3.NbDuplicate);
            Assert.AreEqual(2, file5.NbDuplicate);
        }
Esempio n. 11
0
        public void TestMethodTreeOneDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            root.AddDirectory("c:\\test\\test2");

            foreach (var item in root)
            {
                Assert.AreEqual(item.Name, "c:\\test\\test2");
                Assert.AreEqual(item.Type, "Dir.");
                Assert.AreEqual(item.Size, 0);
            }
        }
Esempio n. 12
0
        public void TestMethodDuplicateMultipleFileMultipleMd5()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            ClassDirectory test1 = root.AddDirectory("c:\\test\\test1");
            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");

            ClassDirectory test3 = test2.AddDirectory("c:\\test\\test2\\test3");

            ClassFile file1 = test3.AddFile("c:\\test\\test2\\test3\\file1", 80, "123");

            test3.AddFile("c:\\test\\test2\\test3\\file2", 60, "123");
            ClassFile file3 = test3.AddFile("c:\\test\\test2\\test3\\file3", 10, "789");

            test1.AddFile("c:\\test\\test1\\file4", 30, "456");
            ClassFile file5 = test2.AddFile("c:\\test\\test1\\file5", 50, "123");


            Assert.AreEqual(2, file1.NbDuplicate);
            Assert.AreEqual(0, file3.NbDuplicate);
            Assert.AreEqual(2, file5.NbDuplicate);
        }
Esempio n. 13
0
        public void TestMethodDuplicateTwoFileSameMd5()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            ClassDirectory test2 = root.AddDirectory("c:\\test\\test2");


            ClassFile file1 = test2.AddFile("c:\\test\\test2\\file1", 80, "123");
            ClassFile file2 = test2.AddFile("c:\\test\\test2\\file2", 60, "123");

            Assert.AreEqual(1, file1.NbDuplicate);
            Assert.AreEqual(1, file2.NbDuplicate);
        }
Esempio n. 14
0
        public void TestMethodTreeOneDir()
        {
            ClassDirectory root = new ClassDirectory("c:\\test");

            root.AddDirectory("c:\\test\\test2");



            foreach (var item in root)
            {
                Assert.AreEqual(item.Name, "c:\\test\\test2");
                Assert.AreEqual(item.Type, "Dir.");
                Assert.AreEqual(item.Size, 0);
            }
        }
Esempio n. 15
0
 private void ScanRep(ClassDirectory root)
 {
     //Listing files
     try
     {
         var lFiles = Directory.EnumerateFiles(root.Name);
         foreach (string f in lFiles) {
             root.AddFile(f, new FileInfo(f).Length);
         }
     }
     catch (Exception e)
     {
         _lstErr.Add(root.Name + "\r\n" + e.Message + "\r\n");
     }
     //Listing directories
     try
     {
         var lDir = Directory.EnumerateDirectories(root.Name);
         foreach (string d in lDir)
         {
             ScanRep(root.AddDirectory(d)); //And we step through
         }
     }
     catch (Exception e)
     {
         _lstErr.Add(root.Name + "\r\n" + e.Message + "\r\n");
     }
 }