public void TestMethodSizeTwoFile() { ClassDirectory root = new ClassDirectory("c:\\test"); ClassFile file1 = root.AddFile("c:\\test\\file1", 80, "123"); ClassFile file2 = root.AddFile("c:\\test\\file2", 60, "123"); Assert.AreEqual(root.Size, file1.Size + file2.Size); }
public void TestMethodDuplicateTwoFileDifferentMd5() { ClassDirectory root = new ClassDirectory("c:\\test"); ClassFile file1 = root.AddFile("c:\\test\\file1", 80, "123"); ClassFile file2 = root.AddFile("c:\\test\\file2", 60, "456"); Assert.AreEqual(0, file1.NbDuplicate); Assert.AreEqual(0, file2.NbDuplicate); }
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); }
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); }
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); }
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); }
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"); } }