Esempio n. 1
0
        public void CanFilterItemsByTrait()
        {
            var filters = new XunitFilters();
            var method1 = new TestMethod("method1", "Display Name 1", MakeTraits("foo", "bar"));
            var method2 = new TestMethod("method2", "Display Name 2", MakeTraits("baz", "biff"));
            var method3 = new TestMethod("method3", "Display Name 3", traits: null);
            filters.IncludedTraits.AddValue("foo", "bar");

            Assert.True(filters.Filter(method1));
            Assert.False(filters.Filter(method2));
            Assert.False(filters.Filter(method3));
        }
Esempio n. 2
0
        public void CanFilterItemsByTrait()
        {
            var filters = new XunitFilters();
            var methodWithFooBar = Mocks.TestCase<ClassUnderTest>("MethodWithFooBar");
            var methodWithBazBiff = Mocks.TestCase<ClassUnderTest>("MethodWithBazBiff");
            var methodWithNoTraits = Mocks.TestCase<ClassUnderTest>("MethodWithNoTraits");
            filters.IncludedTraits.Add("foo", "bar");

            Assert.True(filters.Filter(methodWithFooBar));
            Assert.False(filters.Filter(methodWithBazBiff));
            Assert.False(filters.Filter(methodWithNoTraits));
        }
Esempio n. 3
0
        public void MultipleTraitFiltersAreAnAndOperation()
        {
            var filters = new XunitFilters();
            var method1 = new TestMethod("method1", "Display Name 1", MakeTraits("foo", "bar"));
            var method2 = new TestMethod("method2", "Display Name 2", MakeTraits("baz", "biff"));
            var method3 = new TestMethod("method3", "Display Name 3", traits: null);
            filters.ExcludedTraits.AddValue("foo", "bar");
            filters.ExcludedTraits.AddValue("baz", "biff");

            Assert.False(filters.Filter(method1));
            Assert.False(filters.Filter(method2));
            Assert.True(filters.Filter(method3));
        }
Esempio n. 4
0
        public void MultipleTraitFiltersAreAnAndOperation()
        {
            var filters = new XunitFilters();
            var methodWithFooBar = Mocks.TestCase<ClassUnderTest>("MethodWithFooBar");
            var methodWithBazBiff = Mocks.TestCase<ClassUnderTest>("MethodWithBazBiff");
            var methodWithNoTraits = Mocks.TestCase<ClassUnderTest>("MethodWithNoTraits");
            filters.ExcludedTraits.Add("fOo", "bAr");
            filters.ExcludedTraits.Add("bAz", "bIff");

            Assert.False(filters.Filter(methodWithFooBar));
            Assert.False(filters.Filter(methodWithBazBiff));
            Assert.True(filters.Filter(methodWithNoTraits));
        }
Esempio n. 5
0
        public void EmptyFiltersListAlwaysPasses()
        {
            var filters = new XunitFilters();
            var method = new TestMethod("method1", "Display Name 1", traits: null);

            bool result = filters.Filter(method);

            Assert.True(result);
        }
Esempio n. 6
0
        public void EmptyFiltersListAlwaysPasses()
        {
            var filters = new XunitFilters();
            var method = Mocks.TestCase<ClassUnderTest>("MethodWithNoTraits");

            bool result = filters.Filter(method);

            Assert.True(result);
        }
Esempio n. 7
0
        public static void MultipleNameFiltersAreAnOrOperation()
        {
            var filters = new XunitFilters();
            var method1 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name1");
            var method2 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name2");
            var method3 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass2>("Name3");
            filters.IncludedMethods.Add("Namespace1.ClassInNamespace1+InnerClass1.Name2");
            filters.IncludedClasses.Add("namespace1.classinnamespace1+InnerClass2");

            Assert.False(filters.Filter(method1));
            Assert.True(filters.Filter(method2));
            Assert.True(filters.Filter(method3));
        }
Esempio n. 8
0
        public static void CanFilterFactsByWildcardName()
        {
            var filters = new XunitFilters();
            var method1 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name1");
            var method2 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name2");
            var method3 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name3");
            var method4 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass2>("Name3");
            filters.AddIncludedMethod("*.Name1");
            filters.AddIncludedMethod("Namespace1.*.Name2");
            filters.AddIncludedMethod("*+InnerClass2.*");

            Assert.True(filters.Filter(method1));
            Assert.True(filters.Filter(method2));
            Assert.False(filters.Filter(method3));
            Assert.True(filters.Filter(method4));
        }
Esempio n. 9
0
        public static void EmptyFiltersListAlwaysPasses()
        {
            var filters = new XunitFilters();
            var method = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name1");

            var result = filters.Filter(method);

            Assert.True(result);
        }
Esempio n. 10
0
        public static void CanFilterFactsByFullName()
        {
            var filters = new XunitFilters();
            var method1 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name1");
            var method2 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass1>("Name2");
            var method3 = Mocks.TestCase<Namespace1.ClassInNamespace1.InnerClass2>("Name3");
            filters.IncludedClasses.Add("Namespace1.ClassInNamespace1+InnerClass1");

            Assert.True(filters.Filter(method1));
            Assert.True(filters.Filter(method2));
            Assert.False(filters.Filter(method3));
        }