Example #1
0
		private static void AssertFileNameMatch(string pattern, string input, char excludedCharacter, bool matchExpected, bool appendCanMatchExpected)
		{
			var matcher = new FileNameMatcher(pattern, excludedCharacter);
			matcher.Append(input);
			Assert.AreEqual(matchExpected, matcher.IsMatch());
			Assert.AreEqual(appendCanMatchExpected, matcher.CanAppendMatch());
		}
 ///	<summary>
 /// A copy constructor which creates a new <seealso cref="FileNameMatcher"/> with the
 /// same state and Reset point like <code>other</code>.
 /// </summary>
 /// <param name="other">
 /// another <seealso cref="FileNameMatcher"/> instance.
 /// </param>
 public FileNameMatcher(FileNameMatcher other)
     : this(other._headsStartValue, other._heads)
 {
     if (other == null)
     {
         throw new System.ArgumentNullException("other");
     }
 }
Example #3
0
 private static bool isHostMatch(string pattern, string name)
 {
     FileNameMatcher fn;
     try
     {
         fn = new FileNameMatcher(pattern, null);
     }
     catch (InvalidPatternException)
     {
         return false;
     }
     fn.Append(name);
     return fn.IsMatch();
 }
Example #4
0
		///	<summary>
		/// A copy constructor which creates a new <seealso cref="FileNameMatcher"/> with the
		/// same state and Reset point like <code>other</code>.
		/// </summary>
		/// <param name="other">
		/// another <seealso cref="FileNameMatcher"/> instance.
		/// </param>
		public FileNameMatcher(FileNameMatcher other)
			: this(other._headsStartValue, other._heads)
		{
			if (other == null)
				throw new System.ArgumentNullException ("other");
		}
Example #5
0
 ///	<summary>
 /// A copy constructor which creates a new <seealso cref="FileNameMatcher"/> with the
 /// same state and Reset point like <code>other</code>.
 /// </summary>
 /// <param name="other">
 /// another <seealso cref="FileNameMatcher"/> instance.
 /// </param>
 public FileNameMatcher(FileNameMatcher other)
     : this(other._headsStartValue, other._heads)
 {
 }
Example #6
0
			public FnMatchPattern(string line)
			{
				_matcher = new FileNameMatcher(line, null);
			}
Example #7
0
        public virtual void testReset()
        {
            const string pattern = "helloworld";

            var matcher = new FileNameMatcher(pattern, null);
            matcher.Append("helloworld");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            matcher.Reset();
            matcher.Append("hello");
            Assert.AreEqual(false, matcher.IsMatch());
            Assert.AreEqual(true, matcher.CanAppendMatch());
            matcher.Append("world");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            matcher.Append("to much");
            Assert.AreEqual(false, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            matcher.Reset();
            matcher.Append("helloworld");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
        }
Example #8
0
        public virtual void testCreateMatcherForSuffix()
        {
            const string pattern = "helloworld";

            var matcher = new FileNameMatcher(pattern, null);
            matcher.Append("hello");

            FileNameMatcher childMatcher = matcher.CreateMatcherForSuffix();
            Assert.AreEqual(false, matcher.IsMatch());
            Assert.AreEqual(true, matcher.CanAppendMatch());
            Assert.AreEqual(false, childMatcher.IsMatch());
            Assert.AreEqual(true, childMatcher.CanAppendMatch());
            matcher.Append("world");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(false, childMatcher.IsMatch());
            Assert.AreEqual(true, childMatcher.CanAppendMatch());
            childMatcher.Append("world");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(true, childMatcher.IsMatch());
            Assert.AreEqual(false, childMatcher.CanAppendMatch());
            childMatcher.Reset();
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(false, childMatcher.IsMatch());
            Assert.AreEqual(true, childMatcher.CanAppendMatch());
            childMatcher.Append("world");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(true, childMatcher.IsMatch());
            Assert.AreEqual(false, childMatcher.CanAppendMatch());
        }
Example #9
0
        public virtual void testCopyConstructor()
        {
            const string pattern = "helloworld";

            var matcher = new FileNameMatcher(pattern, null);
            matcher.Append("hello");

            var copy = new FileNameMatcher(matcher);
            Assert.AreEqual(false, matcher.IsMatch());
            Assert.AreEqual(true, matcher.CanAppendMatch());
            Assert.AreEqual(false, copy.IsMatch());
            Assert.AreEqual(true, copy.CanAppendMatch());
            matcher.Append("world");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(false, copy.IsMatch());
            Assert.AreEqual(true, copy.CanAppendMatch());
            copy.Append("world");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(true, copy.IsMatch());
            Assert.AreEqual(false, copy.CanAppendMatch());
            copy.Reset();
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(false, copy.IsMatch());
            Assert.AreEqual(true, copy.CanAppendMatch());
            copy.Append("helloworld");
            Assert.AreEqual(true, matcher.IsMatch());
            Assert.AreEqual(false, matcher.CanAppendMatch());
            Assert.AreEqual(true, copy.IsMatch());
            Assert.AreEqual(false, copy.CanAppendMatch());
        }