Example #1
0
        public void RegularExpressions(string filter, string parsedFilterString)
        {
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsNotNull(parsedFilter);
            Assert.AreEqual(parsedFilter.ToString(), parsedFilterString);
        }
Example #2
0
        public void ExactType(string filterType, bool shouldMatch)
        {
            string filter = filterType + "Type:" + fixture3TypeName;
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsTrue(parsedFilter.IsMatch(fixture3));
            Assert.AreEqual(parsedFilter.IsMatch(fixture4), shouldMatch);
            Assert.AreEqual(parsedFilter.ToString(), "Type(Equality('" + fixture3TypeName + "'), "
                            + (filterType == "Exact" ? "False" : "True") + ")");
        }
Example #3
0
        public void ComplexFilter2()
        {
            string filter = "not ((Type: " + fixture1TypeName + ") or (Type: " + fixture2TypeName + ")) and Type:" + fixture3TypeName + "";
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsNotNull(parsedFilter);
            Assert.AreEqual(parsedFilter.ToString(), "And({ Not(Or({ Type(Equality('" + fixture1TypeName + "'), True), Type(Equality('" + fixture2TypeName + "'), True) })), Type(Equality('" + fixture3TypeName + "'), True) })");
            Assert.IsFalse(parsedFilter.IsMatch(fixture1));
            Assert.IsFalse(parsedFilter.IsMatch(fixture2));
            Assert.IsTrue(parsedFilter.IsMatch(fixture3));
        }
Example #4
0
        public void FilterWithTwoValues(string type1, string type2)
        {
            string filter = "Type:" + type1 + "," + type2;
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsNotNull(parsedFilter);
            Assert.AreEqual(parsedFilter.ToString(), "Type(Or({ Equality('" + type1 + "'), Equality('" + type2 + "') }), True)");
            Assert.IsTrue(parsedFilter.IsMatch(fixture1));
            Assert.IsTrue(parsedFilter.IsMatch(fixture2));
            Assert.IsFalse(parsedFilter.IsMatch(fixture3));
        }
Example #5
0
        public void NotFilter(string type1, string type2)
        {
            string filter = "Type:" + type1 + " and not Type:" + type2;
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsNotNull(parsedFilter);
            Assert.AreEqual(parsedFilter.ToString(), "And({ Type(Equality('" + type1 + "'), True), Not(Type(Equality('" + type2 + "'), True)) })");
            Assert.IsTrue(parsedFilter.IsMatch(fixture1));
            Assert.IsFalse(parsedFilter.IsMatch(fixture2));
            Assert.IsFalse(parsedFilter.IsMatch(fixture3));
        }
Example #6
0
        public void FilterWithOneValue(string type)
        {
            string filter = "Type:" + type;
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsNotNull(parsedFilter);
            Assert.AreEqual(parsedFilter.ToString(), "Type(Equality('" + type + "'), True)");
            Assert.IsTrue(parsedFilter.IsMatch(fixture1));
            Assert.IsFalse(parsedFilter.IsMatch(fixture2));
            Assert.IsFalse(parsedFilter.IsMatch(fixture3));
        }
        public void RoundTripFormatting(string filterExpr)
        {
            Filter <ITestDescriptor> filter = FilterUtils.ParseTestFilter(filterExpr);

            string formattedFilterExpression = filter.ToFilterExpr();
            Filter <ITestDescriptor> filterFromFormattedFilterExpression = FilterUtils.ParseTestFilter(formattedFilterExpression);

            // The exact filter expression may be different (redundant parentheses are lost for
            // example), so we compare the final structure of the filters created by parsing the
            // original expression and the formatted filter expression
            Assert.AreEqual(filterFromFormattedFilterExpression.ToString(), filter.ToString());
        }
Example #8
0
        public void AnyFilterIsReturnedForStar()
        {
            string filter = "*";
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsNotNull(parsedFilter);
            Assert.AreEqual(parsedFilter.ToString(), "Any()");
            Assert.AreSame(parsedFilter.GetType(), typeof(AnyFilter <ITestDescriptor>));
            Assert.IsTrue(parsedFilter.IsMatch(fixture1));
            Assert.IsTrue(parsedFilter.IsMatch(fixture2));
            Assert.IsTrue(parsedFilter.IsMatch(fixture3));
        }
Example #9
0
        public void FilterWithRegexValue(string type, bool caseInsensitive)
        {
            string filter = "Type:" + type + (caseInsensitive ? "i" : "");
            Filter <ITestDescriptor> parsedFilter = FilterUtils.ParseTestFilter(filter);

            Assert.IsNotNull(parsedFilter);
            Assert.AreEqual(parsedFilter.ToString(), "Type(Regex('"
                            + type.Substring(1, type.Length - 2)
                            + "', "
                            + (caseInsensitive ? "IgnoreCase, " : "")
                            + "CultureInvariant), True)");
            Assert.IsTrue(parsedFilter.IsMatch(fixture1));
            Assert.IsFalse(parsedFilter.IsMatch(fixture2));
            Assert.IsFalse(parsedFilter.IsMatch(fixture3));
        }
Example #10
0
        public void FilterWithStars(string filter1, string filter2, bool matches)
        {
            Filter <ITestDescriptor> parsedFilter1 = FilterUtils.ParseTestFilter(filter1);

            Assert.IsNotNull(parsedFilter1);

            Filter <ITestDescriptor> parsedFilter2 = FilterUtils.ParseTestFilter(filter2);

            Assert.IsNotNull(parsedFilter2);

            Assert.AreEqual(parsedFilter1.ToString(), parsedFilter2.ToString());

            Assert.AreEqual(parsedFilter1.IsMatch(fixture1), matches);
            Assert.AreEqual(parsedFilter1.IsMatch(fixture2), matches);
            Assert.AreEqual(parsedFilter1.IsMatch(fixture3), matches);
            Assert.AreEqual(parsedFilter2.IsMatch(fixture1), matches);
            Assert.AreEqual(parsedFilter2.IsMatch(fixture2), matches);
            Assert.AreEqual(parsedFilter2.IsMatch(fixture3), matches);
        }
Example #11
0
 public void InvalidFilter(string filter)
 {
     FilterUtils.ParseTestFilter(filter);
 }
Example #12
0
 public void ValidFiltersTests(string filter)
 {
     // Just making sure they are parsed
     Assert.IsNotNull(FilterUtils.ParseTestFilter(filter));
 }
Example #13
0
 public void AnyFilterIsReturnedForEmptyFilterExpressions(string filter)
 {
     FilterUtils.ParseTestFilter(filter);
 }