Exemplo n.º 1
0
 //[Row(null)]
 public void ToStringTest(Type type)
 {
     string namespaceName = type.Namespace;
     NamespaceFilter<ITestDescriptor> filter = new NamespaceFilter<ITestDescriptor>(
         new EqualityFilter<string>(namespaceName));
     Assert.AreEqual("Namespace(Equality('" + namespaceName + "'))", filter.ToString());
 }
        public void no_filters_means_that_everything_is_revoked()
        {
            var sut    = new NamespaceFilter();
            var actual = sut.IsSatisfiedBy(typeof(NoFilter));

            actual.Should().BeFalse();
        }
Exemplo n.º 3
0
        public void no_filters_means_that_everything_is_revoked()
        {
            var sut    = new NamespaceFilter();
            var actual = sut.IsSatisfiedBy(typeof(NoFilter));

            Assert.AreEqual(actual, false);
        }
Exemplo n.º 4
0
        private Filter <ITestDescriptor> GetNamespaceFilter(TestTreeNode namespaceNode)
        {
            var equalityFilter  = new EqualityFilter <string>(namespaceNode.Id);
            var namespaceFilter = new NamespaceFilter <ITestDescriptor>(equalityFilter);

            if (optionsController.NamespaceHierarchy == NamespaceHierarchy.Flat)
            {
                return(namespaceFilter);
            }

            var filters = new List <Filter <ITestDescriptor> > {
                namespaceFilter
            };

            foreach (var n in namespaceNode.Nodes)
            {
                var node = n as NamespaceNode;

                if (node == null)
                {
                    continue;
                }

                var filter = GetNamespaceFilter(node);

                if (filter != null)
                {
                    filters.Add(filter);
                }
            }

            return(filters.Count > 1 ? new OrFilter <ITestDescriptor>(filters)
                : filters[0]);
        }
Exemplo n.º 5
0
 public void FilterNamespace(NamespaceFilter filter)
 {
     filter.Add(this);
     foreach (var name in Generics)
     {
         name.FilterNamespace(filter);
     }
 }
Exemplo n.º 6
0
        //[Row(null)]
        public void ToStringTest(Type type)
        {
            string namespaceName = type.Namespace;
            NamespaceFilter <ITestDescriptor> filter = new NamespaceFilter <ITestDescriptor>(
                new EqualityFilter <string>(namespaceName));

            Assert.AreEqual("Namespace(Equality('" + namespaceName + "'))", filter.ToString());
        }
Exemplo n.º 7
0
        public static ITypeName GetTypeName(this Type type, TypeNameFlag flags = TypeNameFlag.Default)
        {
            var name   = TypeNameFactory.Create(type, flags);
            var filter = new NamespaceFilter();

            name.FilterNamespace(filter);
            filter.ClearNamespace();
            return(name);
        }
Exemplo n.º 8
0
        public void child_ns_is_configured_to_NOT_be_allowed__so_dont_allow_it()
        {
            var sut = new NamespaceFilter();

            sut.Allow("MicroServer", false);
            var actual = sut.IsSatisfiedBy(typeof(NoFilter));

            Assert.AreEqual(actual, false);
        }
        public void child_ns_is_configured_to_be_allowed__so_allow_it()
        {
            var sut = new NamespaceFilter();

            sut.Allow("Griffin", true);
            var actual = sut.IsSatisfiedBy(typeof(NoFilter));

            actual.Should().BeTrue();
        }
Exemplo n.º 10
0
        public static IMethodName GetDefinitionName(this MethodInfo method, TypeNameFlag flags = TypeNameFlag.Default)
        {
            var name   = new MethodName(method, flags);
            var filter = new NamespaceFilter();

            name.FilterNamespace(filter);
            filter.ClearNamespace();
            return(name);
        }
        public void allow_root_but_reject_specific_child__make_sure_that_the_root_is_allowed()
        {
            var sut = new NamespaceFilter();

            sut.Revoke(typeof(NoFilter).Namespace, false);
            sut.Allow("Griffin", true);
            var actual = sut.IsSatisfiedBy(typeof(GuidFactory));

            actual.Should().BeTrue();
        }
        public void allow_root_but_reject_specific_child()
        {
            var sut = new NamespaceFilter();

            sut.Revoke(typeof(NoFilter).Namespace, false);
            sut.Allow("Griffin", true);
            var actual = sut.IsSatisfiedBy(typeof(NoFilter));

            actual.Should().BeFalse("because a specific filter was set");
        }
Exemplo n.º 13
0
        public void allow_root_but_reject_specific_child()
        {
            var sut = new NamespaceFilter();

            sut.Revoke(typeof(NoFilter).Namespace, false);
            sut.Allow("MicroServer", true);
            var actual = sut.IsSatisfiedBy(typeof(NoFilter));

            Assert.AreEqual(actual, false, "because a specific filter was set");
        }
Exemplo n.º 14
0
        public void allow_root_but_reject_specific_child__make_sure_that_the_root_is_allowed()
        {
            var sut = new NamespaceFilter();

            sut.Revoke(typeof(NoFilter).Namespace, false);
            sut.Allow("MicroServer", true);
            var actual = sut.IsSatisfiedBy(typeof(Guid));

            Assert.AreEqual(actual, true);
        }
Exemplo n.º 15
0
 public void FilterNamespace(NamespaceFilter filter)
 {
     ReturnType.FilterNamespace(filter);
     ExplicitInterface?.FilterNamespace(filter);
     foreach (var name in Generics)
     {
         name.FilterNamespace(filter);
     }
     foreach (var parameter in Parameters)
     {
         parameter.TypeName.FilterNamespace(filter);
     }
 }
Exemplo n.º 16
0
        public void TestOtherNamespaceWithoutChildren()
        {
            var filter = new NamespaceFilter("Bajs", false);

            Assert.False(filter.CanLog(GetType(), LogLevel.Debug));
        }
Exemplo n.º 17
0
        public void TestThisNamespaceWithChildren()
        {
            var filter = new NamespaceFilter("Griffin.Logging.Tests.Filters", true);

            Assert.True(filter.CanLog(GetType(), LogLevel.Debug));
        }
Exemplo n.º 18
0
        public void TestParentNamespaceWithoutChildren()
        {
            var filter = new NamespaceFilter("Griffin.Logging.Tests", false);

            Assert.False(filter.CanLog(GetType(), LogLevel.Debug));
        }
Exemplo n.º 19
0
        private Filter<ITestDescriptor> GetNamespaceFilter(TestTreeNode namespaceNode)
        {
            var equalityFilter = new EqualityFilter<string>(namespaceNode.Id);
            var namespaceFilter = new NamespaceFilter<ITestDescriptor>(equalityFilter);
            
            if (optionsController.NamespaceHierarchy == NamespaceHierarchy.Flat)
                return namespaceFilter;

            var filters = new List<Filter<ITestDescriptor>> { namespaceFilter };

            foreach (var n in namespaceNode.Nodes)
            {
                var node = n as NamespaceNode;

                if (node == null)
                    continue;

                var filter = GetNamespaceFilter(node);

                if (filter != null)
                {
                    filters.Add(filter);
                }
            }

            return filters.Count > 1 ? new OrFilter<ITestDescriptor>(filters)
                : filters[0];
        }