CmisSync.Lib.PathMatcher.PathMatcher.Matches C# (CSharp) Метод

Matches() публичный Метод

Matches the specified localPath and remotePath.
public Matches ( IDirectoryInfo localFolder, IFolder remoteFolder ) : bool
localFolder IDirectoryInfo Local folder.
remoteFolder IFolder Remote folder.
Результат bool
        public bool Matches(IDirectoryInfo localFolder, IFolder remoteFolder)
        {
            return this.Matches(localFolder.FullName, remoteFolder.Path);
        }

Same methods

PathMatcher::Matches ( string localPath, IFolder remoteFolder ) : bool
PathMatcher::Matches ( string localPath, string remotePath ) : bool

Usage Example

Пример #1
0
        public void MatchesTest()
        {
            var matcher = new PathMatcher(this.localpath, this.remotepath);
            Assert.IsTrue(matcher.Matches(this.localpath, this.remotepath));
            string sameSubfolder = "bla";
            Assert.IsTrue(matcher.Matches(Path.Combine(this.localpath, sameSubfolder), this.remotepath + "/" + sameSubfolder));
            sameSubfolder = Path.Combine("sub", "folder");
            Assert.IsTrue(matcher.Matches(Path.Combine(this.localpath, sameSubfolder), this.remotepath + "/" + sameSubfolder));
            string anotherFolder = "another";
            Assert.IsFalse(matcher.Matches(Path.Combine(this.localpath, sameSubfolder), this.remotepath + "/" + anotherFolder));
            string subfolderOfSame = Path.Combine(sameSubfolder, "sub");
            Assert.IsFalse(matcher.Matches(Path.Combine(this.localpath, sameSubfolder), this.remotepath + "/" + subfolderOfSame));
            Assert.IsFalse(matcher.Matches(Path.Combine(this.localpath, subfolderOfSame), this.remotepath + "/" + sameSubfolder));
            string wrongStartingFolder = "wrong";
            try
            {
                matcher.Matches(Path.Combine(this.localpath, wrongStartingFolder), wrongStartingFolder);
                Assert.Fail("Should throw exception on wrong path start");
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            try
            {
                matcher.Matches(wrongStartingFolder, wrongStartingFolder);
                Assert.Fail("Should throw exception on wrong path start");
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            try
            {
                matcher.Matches(wrongStartingFolder, this.remotepath + "/" + wrongStartingFolder);
                Assert.Fail("Should throw exception on wrong path start");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }