ContainsFile() public method

Checks whether the database contains a given file.
public ContainsFile ( string path ) : bool
path string
return bool
Esempio n. 1
0
        public void TestSpecialCharacter()
        {
            string oldPath = Path.Combine(RootPath, "a'b'c");
            string newPath = Path.Combine(RootPath, "'a'b'c'");

            using (Database database = new Database(DatabasePath))
            {
                CreateTestFile(oldPath, 10);
                database.AddFile(oldPath, "1", DateTime.Now, null, FakeHash);
                Assert.True(database.ContainsFile(oldPath));
                Assert.False(database.ContainsFile(newPath));
                database.MoveFile(oldPath, newPath);
                Assert.False(database.ContainsFile(oldPath));
                Assert.True(database.ContainsFile(newPath));
                database.RemoveFile(newPath);
                Assert.False(database.ContainsFile(oldPath));
                Assert.False(database.ContainsFile(newPath));
            }

            using (Database database = new Database(DatabasePath))
            {
                database.AddFolder(oldPath, "1", DateTime.Now);
                Assert.True(database.ContainsFolder(oldPath));
                Assert.False(database.ContainsFolder(newPath));
                database.MoveFolder(oldPath, newPath);
                Assert.False(database.ContainsFolder(oldPath));
                Assert.True(database.ContainsFolder(newPath));
                database.RemoveFolder(newPath);
                Assert.False(database.ContainsFolder(oldPath));
                Assert.False(database.ContainsFolder(newPath));
            }
        }
Esempio n. 2
0
        public void TestMoveFolder()
        {
            using (Database database = new Database(DatabasePath))
            {
                Directory.CreateDirectory(Path.Combine(RootPath, "folder1/folder2"));

                string oldPath = Path.Combine(RootPath, "folder1/folder2", "1.test");
                CreateTestFile(oldPath, 10);
                string newPath = Path.Combine(RootPath, "sub1/folder2", "1.test");

                database.AddFile(oldPath, "1", DateTime.Now, null, FakeHash);
                database.AddFolder(Path.Combine(RootPath, "folder1"), "D1", DateTime.Now);
                database.AddFolder(Path.Combine(RootPath, "folder1/folder2"), "D12", DateTime.Now);
                Assert.True(database.ContainsFile(oldPath));
                Assert.True(database.ContainsFolder(Path.Combine(RootPath, "folder1")));
                Assert.True(database.ContainsFolder(Path.Combine(RootPath, "folder1/folder2")));
                Assert.False(database.ContainsFile(newPath));
                Assert.False(database.ContainsFolder(Path.Combine(RootPath, "sub1")));
                Assert.False(database.ContainsFolder(Path.Combine(RootPath, "sub1/folder2")));
                database.MoveFolder(Path.Combine(RootPath, "folder1"), Path.Combine(RootPath, "sub1"));
                Assert.False(database.ContainsFile(oldPath));
                Assert.False(database.ContainsFolder(Path.Combine(RootPath, "folder1")));
                Assert.False(database.ContainsFolder(Path.Combine(RootPath, "folder1/folder2")));
                Assert.True(database.ContainsFile(newPath));
                Assert.True(database.ContainsFolder(Path.Combine(RootPath, "sub1")));
                Assert.True(database.ContainsFolder(Path.Combine(RootPath, "sub1/folder2")));
            }
        }
Esempio n. 3
0
 public void TestMoveFile()
 {
     using (Database database = new Database(DatabasePath))
     {
         string oldPath = Path.Combine(RootPath, "1.old");
         CreateTestFile(oldPath, 10);
         string newPath = Path.Combine(RootPath, "1.new");
         
         database.AddFile(oldPath, "1", DateTime.Now, null, FakeHash);
         Assert.True(database.ContainsFile(oldPath));
         Assert.False(database.ContainsFile(newPath));
         database.MoveFile(oldPath, newPath);
         Assert.False(database.ContainsFile(oldPath));
         Assert.True(database.ContainsFile(newPath));
     }
 }