public void AcceptsBaseTypeIfSpecified()
        {
            var constraint = new TypeBuildNodeConstraint(typeof(object), null, TypeSelectorIncludes.BaseType);

            Assert.IsTrue(constraint.Matches(typeof(object)));
            Assert.IsTrue(constraint.Matches(typeof(BaseType)));
            Assert.IsTrue(constraint.Matches(typeof(DerivedType)));
            Assert.IsTrue(constraint.Matches(typeof(DerivedType.NestedType)));
            Assert.IsFalse(constraint.Matches(typeof(DerivedType.NestedInternalType)));
            Assert.IsFalse(constraint.Matches(typeof(AbstractType)));
            Assert.IsTrue(constraint.Matches(typeof(DerivedFromAbstractType)));
            Assert.IsFalse(constraint.Matches(typeof(IBase)));
            Assert.IsFalse(constraint.Matches(typeof(IDerived)));
            Assert.IsFalse(constraint.Matches(typeof(InternalType)));
            Assert.IsFalse(constraint.Matches(typeof(InternalAbstractType)));
        }
        public void AcceptsPublicNonAbstractNonInterfaceTypesByDefault()
        {
            var constraint = new TypeBuildNodeConstraint(typeof(object), null, TypeSelectorIncludes.None);

            Assert.IsFalse(constraint.Matches(typeof(object)));
            Assert.IsTrue(constraint.Matches(typeof(BaseType)));
            Assert.IsTrue(constraint.Matches(typeof(DerivedType)));
            Assert.IsTrue(constraint.Matches(typeof(DerivedType.NestedType)));
            Assert.IsFalse(constraint.Matches(typeof(DerivedType.NestedInternalType)));
            Assert.IsFalse(constraint.Matches(typeof(AbstractType)));
            Assert.IsTrue(constraint.Matches(typeof(DerivedFromAbstractType)));
            Assert.IsFalse(constraint.Matches(typeof(IBase)));
            Assert.IsFalse(constraint.Matches(typeof(IDerived)));
            Assert.IsFalse(constraint.Matches(typeof(InternalType)));
            Assert.IsFalse(constraint.Matches(typeof(InternalAbstractType)));
        }
        public void AcceptsOnlyTypesWithTheConfigurationElementTypeIfSpecified()
        {
            var constraint =
                new TypeBuildNodeConstraint(
                    typeof(object),
                    typeof(int),
                    TypeSelectorIncludes.Interfaces | TypeSelectorIncludes.AbstractTypes | TypeSelectorIncludes.BaseType | TypeSelectorIncludes.NonpublicTypes);

            Assert.IsFalse(constraint.Matches(typeof(object)));
            Assert.IsFalse(constraint.Matches(typeof(BaseType)));
            Assert.IsFalse(constraint.Matches(typeof(DerivedType)));
            Assert.IsFalse(constraint.Matches(typeof(DerivedType.NestedType)));
            Assert.IsFalse(constraint.Matches(typeof(DerivedType.NestedInternalType)));
            Assert.IsFalse(constraint.Matches(typeof(AbstractType)));
            Assert.IsTrue(constraint.Matches(typeof(DerivedFromAbstractType)));
            Assert.IsFalse(constraint.Matches(typeof(IBase)));
            Assert.IsFalse(constraint.Matches(typeof(IDerived)));
            Assert.IsFalse(constraint.Matches(typeof(InternalType)));
            Assert.IsFalse(constraint.Matches(typeof(InternalAbstractType)));
        }
            public void DoTestAcceptsTypesFromDifferentLoadContext()
            {
                var newAssembly = Assembly.LoadFrom(AssemblyFileName);

                var constraint =
                    new TypeBuildNodeConstraint(
                        typeof(IBase),
                        null,
                        TypeSelectorIncludes.Interfaces | TypeSelectorIncludes.AbstractTypes | TypeSelectorIncludes.BaseType | TypeSelectorIncludes.NonpublicTypes);

                Assert.IsTrue(constraint.Matches(newAssembly.GetType(typeof(BaseType).FullName, true)));
                Assert.IsTrue(constraint.Matches(newAssembly.GetType(typeof(DerivedType).FullName, true)));
                Assert.IsFalse(constraint.Matches(newAssembly.GetType(typeof(DerivedType.NestedType).FullName, true)));
                Assert.IsFalse(constraint.Matches(newAssembly.GetType(typeof(DerivedType.NestedInternalType).FullName, true)));
                Assert.IsFalse(constraint.Matches(newAssembly.GetType(typeof(AbstractType).FullName, true)));
                Assert.IsFalse(constraint.Matches(newAssembly.GetType(typeof(DerivedFromAbstractType).FullName, true)));
                Assert.IsTrue(constraint.Matches(newAssembly.GetType(typeof(IBase).FullName, true)));
                Assert.IsTrue(constraint.Matches(newAssembly.GetType(typeof(IDerived).FullName, true)));
                Assert.IsFalse(constraint.Matches(newAssembly.GetType(typeof(InternalType).FullName, true)));
                Assert.IsFalse(constraint.Matches(newAssembly.GetType(typeof(InternalAbstractType).FullName, true)));
            }
        public void ConfigurationElementTypeIsReferredToInDisplayString()
        {
            var constraint = new TypeBuildNodeConstraint(typeof(Guid), typeof(double), TypeSelectorIncludes.None);

            Assert.IsTrue(constraint.GetDisplayString().IndexOf("double", StringComparison.OrdinalIgnoreCase) > -1);
        }
        public void BaseTypeIsReferredToInDisplayString()
        {
            var constraint = new TypeBuildNodeConstraint(typeof(Guid), null, TypeSelectorIncludes.None);

            Assert.IsTrue(constraint.GetDisplayString().IndexOf("Guid", StringComparison.OrdinalIgnoreCase) > -1);
        }