Example #1
0
        private FilteringAssemblyLoader CreateLoaderForMarkedAssemblies()
        {
            var markerAttributeType = typeof(MarkerAttribute);
            var attributeFilter     = new AttributeAssemblyLoaderFilter(markerAttributeType);

            return(new FilteringAssemblyLoader(attributeFilter));
        }
        public void AttributeConsidering()
        {
            var filter = new AttributeAssemblyLoaderFilter(typeof(SerializableAttribute)); // attribute type doesn't matter here

            Assert.That(filter.ShouldConsiderAssembly(typeof(AttributeAssemblyLoaderFilterTest).Assembly.GetName()), Is.True);
            Assert.That(filter.ShouldConsiderAssembly(typeof(TestFixtureAttribute).Assembly.GetName()), Is.True);
            Assert.That(filter.ShouldConsiderAssembly(typeof(object).Assembly.GetName()), Is.True);
            Assert.That(filter.ShouldConsiderAssembly(new AssemblyName("name does not matter")), Is.True);
        }
        public void AttributeInclusion()
        {
            var filter = new AttributeAssemblyLoaderFilter(typeof(TestMarkerAttribute));

            Assert.That(filter.ShouldIncludeAssembly(typeof(AttributeAssemblyLoaderFilterTest).Assembly), Is.True);
            Assert.That(filter.ShouldIncludeAssembly(typeof(TestFixtureAttribute).Assembly), Is.False);
            Assert.That(filter.ShouldIncludeAssembly(typeof(object).Assembly), Is.False);
            Assert.That(filter.ShouldIncludeAssembly(typeof(Uri).Assembly), Is.False);

            filter = new AttributeAssemblyLoaderFilter(typeof(CLSCompliantAttribute));
            Assert.That(filter.ShouldIncludeAssembly(typeof(ApplicationAssemblyLoaderFilter).Assembly), Is.True);
            Assert.That(filter.ShouldIncludeAssembly(typeof(AttributeAssemblyLoaderFilterTest).Assembly), Is.False);
            Assert.That(filter.ShouldIncludeAssembly(typeof(TestFixtureAttribute).Assembly), Is.True);
            Assert.That(filter.ShouldIncludeAssembly(typeof(object).Assembly), Is.True);
            Assert.That(filter.ShouldIncludeAssembly(typeof(Uri).Assembly), Is.True);

            filter = new AttributeAssemblyLoaderFilter(typeof(SerializableAttribute));
            Assert.That(filter.ShouldIncludeAssembly(typeof(AttributeAssemblyLoaderFilterTest).Assembly), Is.False);
            Assert.That(filter.ShouldIncludeAssembly(typeof(TestFixtureAttribute).Assembly), Is.False);
            Assert.That(filter.ShouldIncludeAssembly(typeof(object).Assembly), Is.False);
            Assert.That(filter.ShouldIncludeAssembly(typeof(Uri).Assembly), Is.False);
        }